I'd like to add the sum of hours in a week using jquery from a table, when text fields change the total in div total_amount should be updated, but it doesn't seem to be working.
$(function() {
$("[id$=day]").change(function() {
var total = 0;
$('table input[id$=day]').each(function() {
var sum_id = this.id;
total[this.value] += parseInt($('#' + sum_id).val(), 10);
});
$('div.total_amount').html(total);
});
});
And the html is here
<td class="timesheet2"><input type="text" name="daymon" id="monday">
</td>
<td class="timesheet2"><input type="text" name="daytue" id="tuesday">
</td>
<td class="timesheet2"><input type="text" name="daywed" id="wednesday">
</td>
<td class="timesheet2"><input type="text" name="daythurs" id="thursday">
</td>
<td class="timesheet2"><input type="text" name="dayfri" id="friday">
</td>
<td class="timesheet2"><input type="text" name="daysat" id="saturday">
</td>
<td class="timesheet2"><input type="text" name="daysun" id="sunday">
</td>
<td class="timesheet"><div id="total_amount"></div>
</td>