views:

35

answers:

0

Hi,

I'm looking for the best way to trigger (call) a function which will sum all the input fields in all table rows. The problem is, that the field can be manipulated manually (by typing) or with a function - value written to them (which does not trigger an event).

I would like that the sum function would trigger on add/remove row (tr), keypress, focusout...

Btw: i'm cloning the table rows, so they are created dynamically.

Thanks!

$(".val_field:input").live("focusout", function(){
    val = parseFloat( $(this).val() );
    sum += isNaN(val) ? 0 : val;
    $("#sum").val( sum );
});