SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2008
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JavaScript works in IE but not in Firefox

    I have the following javascript:

    <script type="text/javascript">

    var textBlocks = new Array(
    '$4.99',
    '$8.99');

    function changetext(elemid) { var ind = document.getElementById(elemid).selectedIndex; document.getElementById("display").innerHTML=textBlocks[ind]; updateTotal();}function showMe (it, box) { var vis = (box.checked) ? "block" : "none"; document.getElementById(it).style.display = vis; updateTotal();}

    function updateTotal() { var shipping = document.getElementById('shipping'); var shippingValue = shipping.options[shipping.selectedIndex].value; var shippingPrice = parseFloat(shippingValue); var insurance = document.getElementById('modtype'); var insuranceValue = insurance.checked ? insurance.value : 0; var insurancePrice = parseFloat(insuranceValue); var totalPrice = (shippingPrice + insurancePrice).toFixed(2); var totalElement = document.getElementById('totalPrice'); var totalField = document.getElementsByName('total')[0]; totalElement.innerHTML = totalPrice; totalField.value = totalPrice;}

    window.onload = updateTotal;
    </script>

    =============================

    HTML:
    <td width="24%" align="center" valign="middle" bgcolor="#CCE3F1"><strong>$<span id="totalPrice">&nbsp;</span></strong></td>

    =============================

    This code functions in IE, but not in Firefox. Live example:
    http://www.colondietmax.com/order.asp

  2. #2
    SitePoint Evangelist bradical1379's Avatar
    Join Date
    Feb 2007
    Posts
    443
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Javascript:
    Code:
    var insurance = document.getElementById('modtype');
    HTML:
    Code:
    <input name="modtype" type="checkbox" onclick="showMe('div1', this)"  value="1.00" checked="checked" />
    Update the HTML to:
    Code:
    <input id="modtype" name="modtype" type="checkbox" onclick="showMe('div1', this)"  value="1.00" checked="checked" />
    The id for modtype was not found in your code anywhere.

    You should be golden.

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2008
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a million. You Rock!


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
  •