I have created a user-generated table with a quantity input field in each row. I want to trigger a calculation whenever the quantity changes. Since the table can have multiple rows, there will be multiple quantity fields.
The current code snippet listens for changes in the "qty" field, but it only works for the first row of the table. Can anyone suggest how I can make the event listener apply to all instances of the "qty" field?
// When Quantity Changes:
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);
}
Check out the jsfiddle of the code here: http://jsfiddle.net/jDfFU/95/