I have lines of input fields (text) that I need to iterate over, multiplying the values ββin the line and then summing the products. The only solution I could find was to convert input fields to arrays:
var array1 = $('input[id$="txtVal1"]').toArray(); var array2 = $('input[id$="txtVal2"]').toArray(); var temp1; var temp2; var sum=0;
And then repeat and summarize using:
for (i = 0; i < array1.length; i++) { if (array1[i].value.length > 0) {
It works. However, I am just learning jQuery and want to use the canonical method.
source share