title: JQuery: Looping through input elements
body: <p>I have rows of input boxes (text) that I need to iterate over, multiplying values within a row and then summing the products. The only solution I could find is to convert the input boxes to arrays:</p>
  
  <pre><code>var array1 = $('input[id$="txtVal1"]').toArray();
  var array2 = $('input[id$="txtVal2"]').toArray();
  var temp1;
  var temp2;
  var sum=0;
  </code></pre>
  
  <p>And then iterate and sum using:</p>
  
  <pre><code>for (i = 0; i &lt; array1.length; i++) {
      if (array1[i].value.length &gt; 0) { //make sure we have data
          temp1 = parseFloat(array1[i].value);
          temp2 = parseFloat(array2[i].value);
          sum += temp1 * temp2;
      }
  }
  </code></pre>
  
  <p>This works. However I'm just learning JQuery and want to use the canonical method.</p>