title: How to get sum of input values?
body: <p>hello im trying to add input totals to a grand total when any input is changed. i keep getting NaN in the total box. here is my code</p>
  
  <pre><code>&lt;div class="col-md-6"&gt;
      &lt;input type="text" placeholder="Description" class="form-control" id="d"     name="description" /&gt;                          
  &lt;/div&gt;
  
  &lt;div class="col-md-1"&gt;
      &lt;input type="text" placeholder="price." class="form-control" id="q" name="itemprice"/&gt;
  &lt;/div&gt;
  &lt;div class="col-md-1"&gt;
      &lt;input type="text" placeholder="price" class="form-control" id="itemprice" name="itemprice1"/&gt;
  &lt;/div&gt;
  &lt;div class="col-md-2"&gt;
      &lt;input type="text" placeholder="price" class="form-control" id="itemprice" name="itemprice2" onchange="myFunction()"/&gt;
  
  &lt;td&gt;Subtotal&lt;/td&gt;
  &lt;td class="total" id="tot" for="tot"&gt;
      &lt;input type="total" id="total"&gt;
  
  &lt;script type="text/javascript"&gt;
  function myFunction()
  {
      var answer = document.getElementById('total');
      var x = document.getElementsByName('itemprice');
      var y = document.getElementsByName('itemprice1');
      var z = document.getElementsByName('itemprice2');
      var d = document.getElementsByName('itemprice3');
      answer.value = x.value + y.value + z.value + d.value;
  }
  
  &lt;/script&gt;
  </code></pre>