Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
find the sum of an array
Old 01-12-2009, 01:55 AM find the sum of an array
Novice Talker

Posts: 5
Trades: 0
<html>
<title>
PROJECT STA EIDIKA THEMATA/ERGASIES
</title>
<body style="border:1px black solid;">

<script type="text/javascript">
var xmlDoc=null;
if (window.ActiveXObject)
{// code for IE
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}
else if (document.implementation.createDocument)
{// code for Mozilla, Firefox, Opera, etc.
xmlDoc=document.implementation.createDocument(""," ",null);
}
else
{
alert('Your browser cannot handle this script');
}

if (xmlDoc!=null)
{
xmlDoc.async=false;
xmlDoc.load("note4.xml");


var x=xmlDoc.getElementsByTagName("item");

sum = 0;
var score = new Array(13);

for (i=0;i<score.length;i++)
{



title = x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue;

description = x[i].getElementsByTagName("description")[0].childNodes[0].nodeValue;

score[i] = x[i].getElementsByTagName("score")[0].childNodes[0].nodeValue;


document.write(score[i]+ "<br />");

sum = sum + score[i] ;


}

alert(sum);

}
</script>

</body>
</html>


I have writen this code but i cant get the sum as a number..
help
spirtokouto is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-12-2009, 02:52 AM Re: find the sum of an array
Insensus's Avatar
Ultra Talker

Posts: 487
Name: Mark Stegeman
Location: Netherlands, Europe
Trades: 0
sum = sum + Number(score[i]);
__________________
<?php ($helpfull>0)?$talkupation++ : '';?>
Insensus is offline
Reply With Quote
View Public Profile
 
Old 01-12-2009, 03:18 AM Re: find the sum of an array
Novice Talker

Posts: 5
Trades: 0
thank you!!!!
spirtokouto is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to find the sum of an array
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.50269 seconds with 12 queries