Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. var x = parseFloat(document.getElementById("Lang_from").value);
  2.  
  3. var x = parseFloat(Lang_from.value);
  4.  
  5. var x = parseFloat(Lang_from.value);
  6.  
  7. var x = Number(Lang_from.value);
  8.  
  9. var x = + Lang_from.value;
  10.  
  11. const x = +Lang_from.value;
  12.  
  13. const lf = +Lang_from.value;
  14. const lt = +Lang_to.value;
  15. const q = +quantity.value;
  16. const s = +subject.value;
  17. const ft = +file_type.value;
  18.  
  19. var total = (+Lang_from.value) + (+Lang_to.value); // The extra + to coerce to number
  20. total *= quantity.value; // *= same as total = total * quantity.value;
  21. // The extra + not ended if the operation on the value is
  22. // not +
  23. total += +subject.value;
  24. total += +file_type.value;
  25.  
  26. addEventListener("load", function() { // waits for the page to load
  27. calculate.addEventListener("click", calculateTotal);
  28. });
  29.  
  30. // or using arrow function and a slightly earlier event that fires when
  31. // all the HTML content has loaded and been parsed (image and the like may not be ready)
  32. addEventListener("DOMContentLoaded", () => { // waits for the page to load
  33. calculate.addEventListener("click", calculateTotal);
  34. });
  35.  
  36.  
  37. // NOTE that the element id is calculate which conflicted with the JavaScript function
  38. // name calculate. I renamed the function to calculateTotal ( which I would have done
  39. // even if there was no name conflict)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement