title: How to automatically sum input value boxes in an HTML table that share the same name?
body: <p>I have an HTML table with columns of input boxes, and would like the sum of the values in the boxes to be displayed automatically (i.e. without clicking a sum button and updates as the values in the boxes are changed). The number of rows in the table varies as it is dynamically created through velocity.  Below is an example HTML table, I want the sum of the values in the capacity row to be displayed. I am not really sure where to start, I have tried numerous JavaScript code and have been unable to get anything to correctly work. </p>
  
  <pre><code> &lt;table border = "1" id = "table"&gt;
    &lt;TR&gt;
          &lt;TH&gt;Resource&lt;/TH&gt; 
          &lt;TH&gt;Vacation&lt;/TH&gt;
          &lt;TH&gt;Allocation&lt;/TH&gt;
          &lt;TH&gt;Holidays&lt;/TH&gt; 
          &lt;TH&gt;Capacity&lt;/TH&gt;
          &lt;TH&gt;Remainder&lt;/TH&gt;
      &lt;/TR&gt;
  
    #foreach($user in $userList)
    &lt;tr&gt;
    &lt;td&gt;$user.resource&lt;/td&gt;
  
          &lt;td&gt;&lt;input type=text name="vacation" size="6" maxlength="10"&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type=text name="alloc" size="6" maxlength="10"&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type=text name="holidays" size="6" maxlength="10"&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type=text name="capacity" size="6" maxlength="10"&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type=text name="remainder" size="6" maxlength="10"&gt;&lt;/td&gt;
      &lt;/tr&gt;
    #end 
    &lt;tr&gt;
    &lt;td&gt;Total:&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;
    &lt;td class= "capsum"&gt;&lt;input type="text" name="captotal" size="6" maxlength="10"&gt;&lt;/td&gt;
    &lt;td&gt;&lt;input type="text" name="remtotal" size="6" maxlength="10"&gt;&lt;/td&gt;
  
    &lt;/tr&gt;
  
    &lt;/table&gt;
  </code></pre>
  
  <p>There will be multiple rows in the table, and each input box in the capacity column shares the same name. So the sum of the Capacity column should be displayed in the "capsum" input box, and should be calculated automatically and update as the values in the input boxes are changed.  </p>