Topic List | Page List: 1 |
---|---|
Topic | Programmers. I'm making a calculator with Javascript and I'm getting an error |
LastTomorrow 12/15/17 2:11:40 PM #1: | function calculator() { var val1 = theForm.txtval1.value; var val2 = theForm.txtval2.value; var math = document.getElementById("math").value; theForm.Total.value = math; if (math == "add") { document.getElementById("Tol").value = val1 + val2; } if (math == "minus") { document.getElementById("Tol").value = val1 - val2; } if (math == "times") { document.getElementById("Tol").value = val1 * val2; } if (math == "divide") { document.getElementById("Tol").value = val1 / val2; } } When I use it, the subtraction, times, division are correct, but the sum always combines the numbers I entered together. --- Waffle waffle waffle ... Copied to Clipboard! |
Topic List | Page List: 1 |