I haven't done much (or any) jQuery. I found the following script on here to, but I have a question. All the attempts I've tried while searching this site have ruined the script. I only want it sum the values of the other columns if the checkbox is checked.
Here is an example table:
<table id="sum_table" class="example">
<thead>
<tr class="titlerow">
<td class="table-sortable:numeric">Apple</td>
<td class="table-sortable:numeric">Orange</td>
<td class="table-sortable:numeric">Watermelon</td>
<td class="table-sortable:numeric">Turtle</td>
</tr>
</thead>
<tr>
<td class="rowDataSd">52</td>
<td class="rowDataSd">911</td>
<td class="rowDataSd">911</td>
<td><input type="checkbox" name="cb" value="1"></td>
</tr>
<tr>
<td class="rowDataSd">989</td>
<td class="rowDataSd">24</td>
<td class="rowDataSd">911</td>
<td><input type="checkbox" name="cb" value="1"></td>
</tr>
<tr>
<td class="rowDataSd">989</td>
<td class="rowDataSd">911</td>
<td class="rowDataSd">911</td>
<td><input type="checkbox" name="cb" value="1"></td>
</tr>
<tfoot>
<tr class="totalColumn">
<td class="totalCol">Total:</td>
<td class="totalCol">Total:</td>
<td class="totalCol">Total:</td>
<td class="totalCol">Total:</td>
</tr>
</tfoot>
Here's the script:
$('#sum_table tr:first td').each(function(){
var $td = $(this);
var colTotal = 0;
$('#sum_table tr:not(:first,.totalColumn)').each(function(){
colTotal += parseInt($(this).children().eq($td.index()).html(),10);
});
$('#sum_table tr.totalColumn').children().eq($td.index()).html('Total: ' + colTotal);
});
Where would I put an &&, and what exactly would that && be?
I've tried adding &&s, but I'm just not familiar with how to read jQuery. I'd love to learn it and I thought this would be a simple project. Guess not. As always, any help is greatly appreciated.