I have a form with fields like invoice Quantity, Unit Price and Sub total. I want to loop through and get sub total of each input field and finally get sum of sub total. How can I do that on JQuery? Thanks.
My code:
$(document).keyup(function(event) {
var sub_total = 0;
$("#items .targetfields").each(function() {
var qty = parseInt($("#quantity").val());
var rate = parseInt($("#rate").val());
$(".subtotal").val(qty * rate);
});
});
ids
in your selectors.ids
have to be unique in your whole html document, otherwise you might get unexpected results when querying them. – Dennis