title: calculate numbers in html table with javascript
body: <p>I am working on a project where I need to calculate some numbers in html table with javascript. The user can add as much numbers as they need and once they click a button, they'll need to see the end sum. 
  I would like to know how I can do that with javascript, you can find the code below:</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml" &gt;
  &lt;head&gt;
      &lt;title&gt;Javascript Calculator&lt;/title&gt;
  
      &lt;SCRIPT language="javascript"&gt;    
     function Calculate()
  {
  }
      function addRow()
      {
  var table = document.getElementById('table');
  
  var button = document.getElementsByTagName('input')[0];
  
  button.onclick = function() {
      var clone = table.rows[table.rows.length - 2].cloneNode(true);
      clone.cells[0].firstChild.data =
          clone.cells[0].firstChild.data.replace(/(\d+):/,function(str,g1) {
                                                             return (+g1 + 1) + ':';
                                                          });
      table.tBodies[0].appendChild(clone);
  };
   }
      &lt;/SCRIPT&gt;
  &lt;/head&gt;
  
  &lt;input type=button value='Add Row' onclick="addRow()" /&gt;
  &lt;br /&gt;&lt;br /&gt;
  &lt;table cellspacing=0 cellpadding=4 id="table"&gt;
  &lt;tbody&gt;
  &lt;tr&gt;&lt;td&gt;Number 1:&lt;/td&gt;&lt;td&gt;&lt;input value=20 style="width:30px" type=text  maxlength=2/&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Number 2:&lt;/td&gt;&lt;td&gt;&lt;input value=25 style="width:30px" type=text  maxlength=2/&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;tfoot&gt;
  &lt;tr&gt;&lt;td style="border-top:solid 1px black;border-bottom:solid 1px black;"&gt;Sum:&lt;/td&gt;&lt;td style="border-top:solid 1px black;border-bottom:solid 1px black;"&gt;&lt;div&gt;45&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
      &lt;/tfoot&gt;
  &lt;/table&gt;
  &lt;input type=button value='Recalculate Sum' onclick="Calculate()" /&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Any idea how I can solve this?
  Thanks in advance, Laziale</p>