Facebook
From McHalt, 9 Years ago, written in JavaScript.
Embed
Download Paste or View Raw
Hits: 509
  1. function calculate(){
  2.         'use strict';
  3.         var total;
  4.         var ilosc = document.getElementById('ilosc').value;
  5.         var cena = document.getElementById('cena').value;
  6.         var podatek = document.getElementById('podatek').value;
  7.         var rabat = document.getElementById('rabat').value;
  8.         total = ilosc * cena;
  9.         podatek /= 100;
  10.         podatek++;
  11.         total *= podatek;
  12.         podatek = podatek / 100;
  13.         podatek = podatek + 1;
  14.         total = total * podatek;
  15.         total -= rabat;
  16.         document.getElementById('total').value = total;
  17.         return false;
  18. }
  19. function init(){
  20.         'use strict';
  21.         var theForm = document.getElementById('theForm');
  22.         theForm.onsubmit = calculate;
  23. }
  24. window.onload = init;
  25.