I have a user generated table that contains a quantity input field in every row that, when it changes, I'd like to trigger a further calculation. The table can have multiple rows and therefore also multiple instances of the quantity field.
The following snippet listens for a change in "qty" however this only seems to work for the first row of the table. Does anyone know how I can make the event listener apply to all instances of the "qty" field.
// On Quantity Change:
var qtys = document.getElementsByName("qty[]");
var i;
for (i = 0; i < qtys.length; ++i) {
qtys[i].addEventListener("change", totalIt, false);
qtys[i].addEventListener("input", totalIt, false);
}
Here is a jsfiddle of the code... http://jsfiddle.net/jDfFU/95/