I have a form with a table with textfields and adjacent checkboxes, when the checkbox is checked I need to sum the amount of the checked textfieds (amount)
the sum of the amount should be displayed in the
<div id="total" style="color:red">500</div>
<tr class="">
<td style="font-size:11px; padding:3px">3795</td>
<td style="font-size:11px; padding:3px"><input type="text" value="" size="6" name="chq_no"></td>
<td style="font-size:11px; padding:3px"><input type="text" value="0" size="6" name="amount"></td>
<td style="font-size:11px; padding:3px; width:20px"><input type="checkbox" value="3795" name="id"></td>
</tr>
this is my trial which is not working
var sum = 0;
$('checkbox :checked').each(function() {
sum += $(this).parents('tr:first').find('input[name="amount"]').val();
});
$('#total').html(sum);
Aucun commentaire:
Enregistrer un commentaire