title: Javascript calculate tax and total price
body: <p>I'm facing a little issue in calculating total price and tax per product.
  I also made a fiddle: <a href="http://jsfiddle.net/wk4dpfLt/1/" rel="nofollow">http://jsfiddle.net/wk4dpfLt/1/</a></p>
  
  <p>This is a simplified piece of code of my actual code:</p>
  
  <pre><code>&lt;table&gt;
     &lt;tr&gt;
         &lt;td&gt;Product&lt;/td&gt;
         &lt;td&gt;Prijs&lt;/td&gt;
         &lt;td&gt;BTW&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;input type='text'  value='Product1' /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type='text' id='p1' value='10' name='prijs' /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type='text' id='bh1' value='21' name='btw_hoog' /&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;input type='text' value='Product2' /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type='text' id='p2' value='10' name='prijs' /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type='text' id='bh2' value='21' name='btw_hoog' /&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;input type='text' value='Product3' /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type='text' id='p3' value='10' name='prijs' /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type='text' id='bl1' value='6' name='btw_laag' /&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;input type='text' value='Product4' /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type='text' id='p4' value='10' name='prijs' /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type='text' id='bl2' value='6' name='btw_laag' /&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;button id='myBtn'&gt;Bereken&lt;/button&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Totaal:&lt;/td&gt;
          &lt;td&gt;&lt;input type='text' value='' id='totaalprijs' class='totaalprijs' /&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Totaal BTW Laag:&lt;/td&gt;
          &lt;td&gt;&lt;input type='text' value='' id='totaalbtwlaag_input' /&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Totaal BTW Hoog:&lt;/td&gt;
          &lt;td&gt;&lt;input type='text' value='' id='totaalbtwhoog' /&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Totaal incl. BTW:&lt;/td&gt;
          &lt;td&gt;&lt;input type='text' value='' class='totaalinc' /&gt;&lt;/td&gt;
      &lt;/tr&gt;
  </code></pre>
  
  <p>In this piece I have 4 rows of products.
  Product = name of the product, Prijs is the prize of the product and BTW is the tax.
  Now basically what I try to achieve is to fill the 4 rows Totaal, BTW Laag , Totaal BTW Hoog and Totaal incl. BTW when I click on the button.</p>
  
  <p>Totaal is the total sum of prizes. I got this working.
  Totaal BTW Laag is the value of id bl which is 6. 6 is in procent, so I tried (6 / 100) * prize, but this isn't working..</p>
  
  <p>Can anyone point me in the right direction?
  This is my javascript:</p>
  
  <pre><code>function getPrijs()
   {
       var prijzenCount = document.getElementsByName("prijs");
       var total = 0;
           var id= '';
       for(var i = 0; i &lt; prijzenCount.length; i++)
       {
           id = "p"+(i+1);
           total = total +  parseInt(document.getElementById(id).value);
       }
  
  
  
      document.getElementById('totaalprijs').value = total;
  
       calcBtwLaag();
  
   }
  
  function calcBtwLaag()
  {
  
     var btwlaagCount = document.getElementsByName("btw_laag");
       var total = 0;
           var id= '';
           var prijsid = '';
       for(var i = 0; i &lt; btwlaagCount.length; i++)
       {
           id = "bl"+(i+1);
           prijsid = "prijs_laag_"+(i+1);
  
           if(isNaN(prijsid)) {
               document.getElementsByName(prijsid).value = 0;
               var prijsvalue = parseInt(document.getElementsByName(prijsid).value);
               var btw_laag_procent = parseInt(document.getElementById(id).value);
               var btw_laag_result = (btw_laag_procent / 100) * prijs;
               alert(btw_laag_result);
  
               total = total +  parseInt(btw_laag_result);
           }
       }
  
  
  
      document.getElementById('totaalbtwlaag_input').value = total;
       return total;
  }
  
  function test()
  {
   alert(document.getElementById('b3').value);   
  }
  
  myBtn.addEventListener('click', function(event) {
    getPrijs();
  });
  </code></pre>