title: How get total sum from input box values using Javascript?
body: <p>I am not perfect in Javascript.. I want to show total sum of values entered in qty input boxes in next input box named total without refreshing page. Can anyone will help me to figure it out..?</p>
  
  <p>Here is javascript</p>
  
  <pre><code> &lt;script type="text/javascript"&gt; 
   var howmanytoadd = 2;
   var rows;
  
   function calc() {
       var tot = 0;
       for (var i = 0; i &lt; rows.length; i++) {
           var linetot = 0;
           rows[i].getElementsByTagName('input')[howmanytoadd].value = linetot;
           tot += linetot;
       }
       document.getElementById('total').value = tot
   }
   onload = function () {
       rows = document.getElementById('tab').getElementById('qty1');
       for (var i = 0; i &lt; rows.length; i++) {
           rows.getElementsByTagName('input')[i].onkeyup = calc;
       }
   }
  &lt;/script&gt;
  </code></pre>
  
  <p>Here is my html code:</p>
  
  <pre><code>Qty1 : &lt;input type="text" name="qty1" id="qty"/&gt;&lt;br&gt;
  Qty2 : &lt;input type="text" name="qty2" id="qty"/&gt;&lt;br&gt;
  Qty3 : &lt;input type="text" name="qty3" id="qty"/&gt;&lt;br&gt;
  Qty4 : &lt;input type="text" name="qty4" id="qty"/&gt;&lt;br&gt;
  Qty5 : &lt;input type="text" name="qty5" id="qty"/&gt;&lt;br&gt;
  Qty6 : &lt;input type="text" name="qty6" id="qty"/&gt;&lt;br&gt;
  Qty7 : &lt;input type="text" name="qty7" id="qty"/&gt;&lt;br&gt;
  Qty8 : &lt;input type="text" name="qty8" id="qty"/&gt;&lt;br&gt;
  &lt;br&gt;&lt;br&gt;
  Total : &lt;input type="text" name="total" id="total"/&gt;
  </code></pre>
  
  <p>here is screen shot
  <img src="https://i.stack.imgur.com/nN1FK.jpg" alt="here is screen shot"></p>