Results 1 to 2 of 2

Thread: code not working in firefox

  1. #1
    Join Date
    Sep 2009
    Location
    pakistan
    Posts
    28
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Exclamation code not working in firefox

    hi fellows im totaly new to javascript , i wrote the following code which is working with IE8 but not with firefox 3.6 any could plz help me
    <script type="text/javascript">
    function calculate(field){
    var salePrice = document.testForm.price.value;
    var discount = testForm.discnt.options[testForm.discnt.selectedIndex].value;
    var amount = salePrice * discount/100;
    document.testForm.total.value = amount;
    }
    </script>

    <form name="testForm" id="testForm">
    <input type="text" name="price" id="price" value="0" onchange="calculate(this);" />
    <select name="discnt" id="discnt" onchange="calculate(this);">
    <option value="10">10%</option>
    <option value="20">20%</option>
    <option value="30">30%</option>
    </select>
    <input type="text" name="total" id="total" value="0" />
    </form>

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Pretty non-standard, so I'll just make it work rather than get into the business of 'how it should be':

    Code:
    function calculate(field){
    var salePrice = document.testForm.price.value;
    var discount = document.testForm.discnt.options[document.testForm.discnt.selectedIndex].value;
    var amount = salePrice * discount/100;
    document.testForm.total.value = amount;
    }
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •