I didn't know a good title for my problem, this is why I didn't search.
My problem is the following:
I have a HTML code, for example:
<input type="text" id="product_qty_1" value="12" />
<input type="text" id="product_qty_2" value="21" />
<input type="text" id="product_qty_3" value="45" />
I'd like to make a sum of the values by jQuery, but this need to be automatic, because we can't know how many inputs
are there.
I don't know, what to do with the selector input[id*="product_qty_"]
to get it working, and make a sum of the values!
Thanks in advance!
var total=0;
$("input[type='text']").each(function() {
total += parseInt(this.value, 10);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With