So i have this code that I'm trying to get it to add up all the sums plus there quantities. How it works now it only adds one of the items. What am i missing?
function addSubTotal() {
var subTotal = 0;
var total = 0;
$("#items").find("#itemadd").each(function() {
var qty = parseInt($(this).find("#qty").val());
var rate = parseInt($(this).find("#price").html());
subTotal += qty * rate;
});
$("#subTotal").html(subTotal);
}
and this is the code i use to dynamically add it
function addItem(a, b) {
$("#items").append("<div id=itemadd> <span id=remove>remove</span> <span id=item>" + a + "</span> <input id=qty type=number autocomplete=off value=2> <span id=price>" + b + "</span></div>");
addSubTotal();
}