(e-mail address removed) said
Post a sample of your initial effort. Putting your data in a TBODY is
not the best way to accomplish it. Place it in a TD element with ID's
that correspond to the columns.
Yes, a TBODY element only takes TR elements as its children, which take only
TD (and TH) as children. They do accept your raw text as child.
But giving every TD an ID is wasteful. Once you have a reference to the
TABLE or TBODY element, you can walk through its childnodes and collect the
data from the TD's.
A quick and simple example, catering for different amounts of cells per row
but not for any additional markup in the TD's:
function sumup() {
var t = [], c, d = document.getElementById( 'sumtable' ),
r = d.rows, i = r.length - 1, lastrow = r
;
while(i--) { c = r.cells; j = c.length;
while(j--) { if( !t[j] ){ t[j] = 0; }
t[j] += parseFloat( c[j].firstChild.nodeValue );
}
}
j = t.length; while(j--) {
if( lastrow.cells[j] ) { lastrow.cells[j].firstChild.nodeValue = t[j]; }
}
}
See it in action at
< http://4umi.com/web/javascript/tablesum.htm >