title: Get sum of the values from form fields with JS/jQuery
body: <p>I have dynamic form like:</p>
  
  <pre><code>&lt;form id="formaa"&gt;
  &lt;div class="row"&gt;
    &lt;input type="text" name="item" class="item"&gt;&lt;/input&gt;
    &lt;input type="text" name="quant" class="quant"&gt;&lt;/input&gt;
    &lt;input type="text" name="price" class="price" onkeyup="update();"&gt;&lt;/input&gt;
    &lt;input type="text" name="sum" id="suma" size="10" disabled="disabled"/&gt;
  &lt;/div&gt;
  &lt;div class="row"&gt;
    &lt;input type="text" name="item" class="item"&gt;&lt;/input&gt;
    &lt;input type="text" name="quant" class="quant"&gt;&lt;/input&gt;
    &lt;input type="text" name="price" class="price" onkeyup="update();"&gt;&lt;/input&gt;
    &lt;input type="text" name="sum" id="suma" size="10" disabled="disabled"/&gt;
  &lt;/div&gt;    
  &lt;!-- ... many more rows --&gt;
  &lt;input type="text" disabled id="total" name="tot"&gt;&lt;/input&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>What I'm trying to do is multiply item quantity and price and get total sum in sum field for each item seperately (not all items total sum).</p>
  
  <p>What I have achiecved is this function, but it seems counting total sum of all items together not seperately and this working with first default field row, when I add new set of fields and fill them with information both, fields (and other later added) sum values become NaN..If I remove all added field sets and leave the first form fows set, number is working again.. What is the problem here?</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function update() {
    var total = 0;
    $("#formaa div.row").each(function(i,o){
      total += $(o).find(".quant").val() *
          $(o).find(".price").val();
           if(!isNaN(total) &amp;&amp; total.length!=0) {
                  sum += parseFloat(total);
              }
    });
    $("#formaa div.row #suma").val(total);
  }
  &lt;/script&gt;
  </code></pre>