Forum Moderators: open
JavaScript is recognizing the types of variables here as string and rather than use a mathematical addition calculation, JavaScript is using string concatenation to combine the two strings.
JavaScript has a few built-in functions for handling conversion of strings to numbers including
parseIntand
parseFloatfor integers and floats. There is also a
Number()function. You might also consider the unary plus operator. Fast and easy:
function tipp()
{
var a = +document.getElementById("textbox1").value;
var b = +document.getElementById("textbox2").value;
var c = a + b;
myform.total.value = c;
}