LogFAQs > #892275460

LurkerFAQs, Active DB, DB1, Database 2 ( 09.16.2017-02.21.2018 ), DB3, DB4, DB5, DB6, DB7, DB8, DB9, DB10, DB11, DB12, Clear
Topic List
Page List: 1
TopicProgrammers. 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