Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    dcp
    dcp is offline
    New to the CF scene
    Join Date
    Jan 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Calculation Function Works in Firefox Not in IE

    The function below generates a value in Firefox but nothing in Explorer. Any help or insight would be appreciated.

    dcp



    function calcTotal()
    {
    var subtotal = document.getElementById('subtotal').firstChild.nodeValue;
    var postage = document.forms['frmMultipleSelects'].elements['postage'].value;
    document.getElementById('total').firstChild.nodeValue=parseInt(subtotal)+parseInt(postage)+'.00';
    //set the value of the hiddden form elements.
    document.forms['frmMultipleSelects'].elements['total'].value=document.getElementById('total').firstChild.nodeValue;

    }

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    How your element 'subtotal' looks like?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    dcp
    dcp is offline
    New to the CF scene
    Join Date
    Jan 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Subtotal is calculated with the following function, this works in both FF and IE:

    function calcSubTotal()
    {
    //get the last coloumn in table [1]
    //var table = document.getElementsByTagName("table")[8];
    var table = document.getElementById('orderList');
    var nodeList = table.getElementsByTagName("tr");
    var row, cell, price, subtotal;
    //set the subtotal amount to zero so we get a clean calculation.
    document.getElementById('subtotal').firstChild.nodeValue='0.00';
    //i needs to be 1 because row 0 is not a form element. It is just the header info
    for (var i = 1; i < nodeList.length; i++)
    {
    row=nodeList[i];
    cell=row.getElementsByTagName("td")[4];
    price= cell.getElementsByTagName("span")[1].firstChild.nodeValue;
    subtotal= parseInt(document.getElementById('subtotal').firstChild.nodeValue)+parseInt(price);
    //we at the '.00' to make it look like money syntax. we can do that since everythign ends in .00
    document.getElementById('subtotal').firstChild.nodeValue=subtotal+".00";
    }
    //set the value of the hiddden form elements.
    document.forms['frmMultipleSelects'].elements['subtotal'].value=document.getElementById('subtotal').firstChild.nodeValue;

    }

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    I have asked you something else
    How your element 'subtotal' looks like?

    Anyway, looking at:
    document.forms['frmMultipleSelects'].elements['subtotal'].value=document.getElementById('subtotal').firstChild.nodeValue;

    I see that you have two elements, one with id='subtotal', one with name='subtotal'. Change one of them (for instance id="subtotalID") to avoid errors
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #5
    dcp
    dcp is offline
    New to the CF scene
    Join Date
    Jan 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the tip. Made modification, which had no effect on calculation.

    Subtotal is span: <span id="subtotal">0.00</span>

    dcp


  •  

    Posting Permissions

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