seoppc
seoppc

Reputation: 2824

jquery table rows calculation

Here is table code...

<tr>
<td class="installationcharge">500</td>
<td class="supportcharge">300</td>
<td class="totalcharges">800</td>
</tr>
    <tr>
<td class="installationcharge">200</td>
<td class="supportcharge">400</td>
<td class="totalcharges">600</td>
</tr>
<tfoot>
<tr><td>Total :</td>
<td class="totalinstcharges"></td>
<td class="totalsuppcharges"></td>
<td class="totalchartotal"></td>
</tr>
</tfoot>

I am trying to calculate and post of all installationcharge, supportcharge, totalcharges in their tfoot total td. I have tried to use jquery each function but no luck, can you help out please. thanks.

Upvotes: 0

Views: 693

Answers (1)

Headshota
Headshota

Reputation: 21439

var sum1 = 0;
$('.installationcharge').each(function(){
  sum1+= parseFloat($(this).html());
});

$('.totalinstcharges').html(sum1);

and for other data in the same way.

Upvotes: 3

Related Questions