I have the below table
<table class="authors-list" border=0 id="ordertable">
<tr>
<td>Cubic Meters</td><td>Cubes per Bundle</td><td>Total Bundles</td>
<tr>
<td><input type="text" name="cubicmeters1" id="cubicmeters1" value="1.38"></td>
<td><input type="text" name="cubesperbundle1" id="cubesperbundle1" value="1.485"></td>
<td><input type="text" name="bundles1" id="bundles1"></td>
</tr>
<tr>
<td><input type="text" name="cubicmeters2" id="cubicmeters2" value="1.38"></td>
<td><input type="text" name="cubesperbundle2" id="cubesperbundle2" value="1.485"></td>
<td><input type="text" name="bundles2" id="bundles2"></td>
</tr>
<tr>
<td><input type="text" name="cubicmeters3" id="cubicmeters3" value="1.38"></td>
<td><input type="text" name="cubesperbundle3" id="cubesperbundle3" value="1.485"></td>
<td><input type="text" name="bundles3" id="bundles3"></td>
</tr>
</table>
what I want to do is loop through each table row and perform a math function against two inputs, and populate the result into a third input.
Fiddle is here: http://jsfiddle.net/ttZtX/1/
So here is my attempt at the jquery:
$("table.authors-list").find('input[name^="cubicmeters1"]').each(function () {
cubes += +$(this).closest('tr').find('input[name^="cubicmeters"]').val();
cubesperbundle += +$(this).closest('tr').find('input[name^="cubesperbundle"]').val();
+$(this).closest('tr').find('input[name^="bundles"]').val((cubes*cubesperbundle).toFixed(2));
});
This simply produces no result or error and the input is not populated.
To summarize, my requirement is for jquery to loop through each row, multiply cubicmeters by cubesperbundle and populate bundles with the result.
simple enough but I just cant get it right.
Any help would be appreciated.
Thanks in advance...