Jquery library helps a lot. It simplify and decrease coding time for all develppers
Here is how you can sum column of a Html table that uses tbody, thead, tr and td or anything
The first and all you need an ID of your tag. either a table or thead...td
<table>
My headers goes here
thead > <tr><th > </th></thead>
the header is Outside of my tData . Thus i can sum all the data in colum. Else if you have the header WithHeader = true when u call the function in (**)
<script type="text/javascript">
pretty easy.. If U have problem figuring it out should me an email.
$(document).ready(
function() {
$(
"#ProspectIn").html(JquerySum("firstData", 3, false));
$(
"#ProspectOut").html(JquerySum("firstData", 5, false));
$(
"#Prospect").html(JquerySum("firstData", 7, false));
$(
"#Client").html(JquerySum("firstData", 8, false));
});
</script>
(**)
function JquerySum(tagId, columnIndex, WithHeader ) {
var sum= 0;
$(
"#" + tagId+ " tr" + (WithHeader ? ":gt(0)" : ""))
.children(
function() {
sum+= parseInt($(
this).html());
});
return sum;
}
"td:nth-child(" + columnIndex + ")")
.each(
"td:nth-child(" + columnIndex + ")")
.each(
function() {
sum+= parseInt($(
this).html());
});
return sum;
}