I have a jquery script on a page that's coming together, thanks to code and people here, and i'm stuck at a point where I need to call a part of a larger function. I'm not sure how to break into multiple functions i think. Everything runs correctly when i create dynamic input fields and it totals up some amount fields into a totals box, but if i don't create new input boxes then it don't get that part i need to total up these inputs. Here is a sample of what i have so far with a comment in the code where i need help:
// ** Need help to call just this part when text is entered/changed in any of the 'amount' fields **
var total = 0;
$('input[name^="Amount"]').each(function () {
total += parseInt(this.value, 10) || 0;
if (this.value.length === 0) this.value = 0;
});
$('#Totals').val(total);