title: how can i calculate the sum of a column in a dynamically newly added row using javascript?
body: <p>I am newbie in javascript and cakephp. I have added a new row using javascript and now I want to calculate the sum of the column "amount" whenever I fill the amount field.
  HTML code for adding new field :</p>
  
  <pre><code>&lt;table id="voucher_line"  style="width:750px; font-size:13px;"&gt;
  &lt;tr&gt;
      &lt;th&gt;Others Component&lt;/th&gt;
      &lt;th&gt;Others GoB&lt;/th&gt;
      &lt;th&gt;Amount&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr id="voucher_"&gt;
      &lt;td style="width:150px;"&gt;&lt;?php echo $this-&gt;Form-&gt;input('DebitVoucherLine.0.coa_component_id',array('options'=&gt;$coa_components,'type'=&gt;'select','label'=&gt;false));?&gt;&lt;/td&gt;
  
      &lt;td style="width:150px;"&gt;&lt;?php echo $this-&gt;Form-&gt;input('DebitVoucherLine.0.level_five_id',array('type'=&gt;'select','label'=&gt;false));?&gt;&lt;/td&gt;
  
      &lt;td style="width:204px;"&gt;&lt;?php echo $this-&gt;Form-&gt;input('DebitVoucherLine.0.amount', array('label'=&gt;false, 'type'=&gt;'text'));?&gt;&lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p></p>
  
  <p>And the javascript:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
  $(":button#add").click(function() {
  var clonedRow = $("#voucher_line tr:last").clone();
  var newIndex = (document.getElementById('voucher_line').rows.length-1);
  
  clonedRow[0].id = 'voucher_' + newIndex;
  $.each($('input, select', clonedRow), function(i, val){
      val.name = val.name.replace((newIndex - 1), newIndex);
      val.id = val.id.replace((newIndex - 1), newIndex);
      val.value = '';
  })
  $("#voucher_line").append(clonedRow); 
  });
  
  $(":button#remove").click(function(){ 
  if ($("#voucher_line tr").length != 2) {
   $("#voucher_line tr:last").remove();
  }   
  });
  
  &lt;/script&gt;
  </code></pre>
  
  <p>Any help would be appreciated.
  Thanks in advance.</p>