VATulator - online VAT calculator


/ Published in: JavaScript
Save to your folder(s)

<p>
<p><b>VAT rate:</b>

<p><b>Net price:</b>

<p><b>Gross price:</b>

<p><b>Tax amount:</b>

</p>


Copy this code and paste it in your HTML
  1. function net_change() {
  2. var vat_rate = document.getElementById('vat_rate');
  3. var net_price = document.getElementById('net_price');
  4. var gross_price = document.getElementById('gross_price');
  5. var tax_amount = document.getElementById('tax_amount');
  6. gross_price.value = net_price.value *(1+(vat_rate.value/100));
  7. tax_amount.value = gross_price.value - net_price.value;
  8. }
  9.  
  10. function gross_change() {
  11. var vat_rate = document.getElementById('vat_rate');
  12. var net_price = document.getElementById('net_price');
  13. var gross_price = document.getElementById('gross_price');
  14. var tax_amount = document.getElementById('tax_amount');
  15. net_price.value = gross_price.value - (gross_price.value * (vat_rate.value/100));
  16. tax_amount.value = gross_price.value - net_price.value;
  17. }
  18.  
  19. function amount_change() {
  20. var vat_rate = document.getElementById('vat_rate');
  21. var net_price = document.getElementById('net_price');
  22. var gross_price = document.getElementById('gross_price');
  23. var tax_amount = document.getElementById('tax_amount');
  24. net_price.value = ((tax_amount.value / vat_rate.value)*100);
  25. gross_price.value = Number(net_price.value) + Number(tax_amount.value);;
  26. }
  27.  
  28.  
  29. function vat_change() {
  30. var vat_rate = document.getElementById('vat_rate');
  31. var net_price = document.getElementById('net_price');
  32. var gross_price = document.getElementById('gross_price');
  33. var tax_amount = document.getElementById('tax_amount');
  34. net_price.value = gross_price.value - (gross_price.value * (vat_rate.value/100));
  35. gross_price.value = net_price.value *(1+(vat_rate.value/100));
  36.  
  37. }
  38.  
  39.  
  40. // Добавляет слушателя событий для таблицы
  41. var vat_rate = document.getElementById('vat_rate');
  42. var net_price = document.getElementById('net_price');
  43. var gross_price = document.getElementById('gross_price');
  44. var tax_amount = document.getElementById('tax_amount');
  45.  
  46. vat_rate.addEventListener("input", vat_change, false);
  47. net_price.addEventListener("input", net_change, false);
  48. gross_price.addEventListener("input", gross_change, false);
  49. tax_amount.addEventListener("input", amount_change, false);

URL: https://vatulator.com/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.