Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var x = parseFloat(document.getElementById("Lang_from").value);
- var x = parseFloat(Lang_from.value);
- var x = parseFloat(Lang_from.value);
- var x = Number(Lang_from.value);
- var x = + Lang_from.value;
- const x = +Lang_from.value;
- const lf = +Lang_from.value;
- const lt = +Lang_to.value;
- const q = +quantity.value;
- const s = +subject.value;
- const ft = +file_type.value;
- var total = (+Lang_from.value) + (+Lang_to.value); // The extra + to coerce to number
- total *= quantity.value; // *= same as total = total * quantity.value;
- // The extra + not ended if the operation on the value is
- // not +
- total += +subject.value;
- total += +file_type.value;
- addEventListener("load", function() { // waits for the page to load
- calculate.addEventListener("click", calculateTotal);
- });
- // or using arrow function and a slightly earlier event that fires when
- // all the HTML content has loaded and been parsed (image and the like may not be ready)
- addEventListener("DOMContentLoaded", () => { // waits for the page to load
- calculate.addEventListener("click", calculateTotal);
- });
- // NOTE that the element id is calculate which conflicted with the JavaScript function
- // name calculate. I renamed the function to calculateTotal ( which I would have done
- // even if there was no name conflict)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement