anyone have a quick way to loop through an array using javascript and return a total. the array is a form element index array all named the same such as hoursworked[] because the array is generated by a php while loop.
Bernard Marx
8:29 am on Dec 13, 2006 (gmt 0)
Array.prototype.getTotal = function() { var total = k = 0; while(k<this.length) total += this[k++]; return total; }
var allHours = [1,2,3];
var total = allHours.getTotal();
// Assuming that all the values are actually numbers of course!