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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Oct 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Simple addition problems

    This code should add the value from the xml element, and add it to distance.
    However, instead of distance increasing in size, it returns the value...'05678', rather than 26.

    What am i doing wrong??

    Much appreciated.

    PHP Code:
    function calc_distance()
                {
                    var 
    xmlDoc.getElementsByTagName('distance');
                    var 
    distance 0;
                    
                    for ( 
    0y.lengtha++ )
                    {
                        
    distance += y[a].firstChild.nodeValue;
                        
                        
    alert(distance);
                    }
                    
                } 

  • #2
    gph
    gph is offline
    Regular Coder
    Join Date
    Apr 2005
    Posts
    161
    Thanks
    0
    Thanked 0 Times in 0 Posts
    alert(typeof distance)

    parseFloat(y[a].firstChild.nodeValue)


  •  

    Posting Permissions

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