trying to sum all elements in the array "number" have in shown in the form "output" when user clicks on the button, im using a example i found on the net but cant seem to make it owrk or any other example if any can pls help me to understand thanks
[COLOR="#EE82EE"]<body>
<script type="text/javascript">
var number = [];
Array.prototype.sum = function()
{
for (var i = 0, L = this.length, sum = 0; i < L; sum += this[i++]);
return sum(document.getElementById("output").value);
}
function myFunction() {
var x = document.getElementById("box");
number.push(document.getElementById("input").value);
x.innerHTML = number.join('<br/>');
}
function myReset() {
number=[]
number.splice(0);
var x = document.getElementById("box");
x.innerHTML = "";
x.innerHTML = number.join('<br/>');
}
Bookmarks