I'm having a trouble on how can I get the total amount column based on the status. Currently I only manage sum all of my amount column. The thing is I want to get the value of sum amount of paid and unpaid amount status, for example like the image below the Paid total should 15000 and the Unpaid should 10000. It would be great if anybody could figure out where I am doing something wrong. thank you so much in advance
var tds = document.getElementById('table').getElementsByTagName('td');
var sum = 0;
for(var i = 0; i < tds.length; i ++) {
if(tds[i].className == 'count-me') {
sum += isNaN(tds[i].innerHTML) ? 0 : parseInt(tds[i].innerHTML);
}
}
document.getElementById('table').innerHTML += '<tr><td>' + sum + '</td><td>total</td></tr>';
<table id="table">
<tr>
<th >Status</th>
<th >AMOUNT</th>
</tr>
<tr>
<td >Paid</td>
<td class="count-me">5000</td>
</tr>
<tr>
<td >Paid</td>
<td class="count-me"> 5000</td>
</tr>
<tr>
<td >Unpaid</td>
<td class="count-me">5000</td>
</tr>
<tr>
<td >Unpaid</td>
<td class="count-me">5000</td>
</tr>
<tr>
<td >Paid</td>
<td class="count-me">5000</td>
</tr>
</table>
