dennis231
asked on
javascript for calculating total for a column
In my HTML document, I have a table contains following fields:
StudentID|ExamScore1|ExamS core2
00001|90|100
00002|70|100
00003|60|80
How do I write a javascript to calculate the total for ExamScore1 and ExamScore2 columns? So my table will look like this:
00001|90|100
00002|70|100
00003|60|80
Total|220|280
Thanks for your help.
StudentID|ExamScore1|ExamS
00001|90|100
00002|70|100
00003|60|80
How do I write a javascript to calculate the total for ExamScore1 and ExamScore2 columns? So my table will look like this:
00001|90|100
00002|70|100
00003|60|80
Total|220|280
Thanks for your help.
You mean HTML table? If so then is the number of rows going to remain the same?
ASKER
Yes, it is a html table, but the number of rows will be changed from time to time.
Sample table:
<table border="1" width="822">
<tr>
<td width="266">StudentID</td>
<td width="266">
<p><span class="value">ExamScore1</ span></p>
</td>
<td width="266">
<p><span class="value">ExamScore2</ span></p>
</td>
</tr>
<tr>
<td width="266">
<p><span class="value">00001</span> </p>
</td>
<td width="266">90</td>
<td width="266">100</td>
</tr>
<tr>
<td width="266">
<p><span class="value">00002</span> </p>
</td>
<td width="266">70</td>
<td width="266">100</td>
</tr>
<tr>
<td width="266">
<p><span class="value">00003</span> </p>
</td>
<td width="266">60</td>
<td width="266">80</td>
</tr>
<tr>
<td width="266" bgcolor="aqua">Total</td>
<td width="266" bgcolor="aqua"><b>220 <-calculate total</b></td>
<td width="266" bgcolor="aqua">
<p><b>280 <-calculate total</b></p>
</td>
</tr>
</table>
Sample table:
<table border="1" width="822">
<tr>
<td width="266">StudentID</td>
<td width="266">
<p><span class="value">ExamScore1</
</td>
<td width="266">
<p><span class="value">ExamScore2</
</td>
</tr>
<tr>
<td width="266">
<p><span class="value">00001</span>
</td>
<td width="266">90</td>
<td width="266">100</td>
</tr>
<tr>
<td width="266">
<p><span class="value">00002</span>
</td>
<td width="266">70</td>
<td width="266">100</td>
</tr>
<tr>
<td width="266">
<p><span class="value">00003</span>
</td>
<td width="266">60</td>
<td width="266">80</td>
</tr>
<tr>
<td width="266" bgcolor="aqua">Total</td>
<td width="266" bgcolor="aqua"><b>220 <-calculate total</b></td>
<td width="266" bgcolor="aqua">
<p><b>280 <-calculate total</b></p>
</td>
</tr>
</table>
I can do it for you tomorrow if you can wait. Time for me to sleep now..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.