+ 4
Help in Javascript
Why does not the program return the result of the addition and only print the numbers? https://code.sololearn.com/W4k1Y7IBqxl2/#js
5 Respostas
+ 7
That's because the values you're using are strings, and the + concatenates them. You need to convert those strings to the type of number you want to use. If for example you want to convert them to int, you have to use parseInt.
For example:
function addition()
{
var x = document.getElementById("pole1").value;
var y = document.getElementById("pole2").value;
document.getElementById("result").innerHTML = parseInt(x)+parseInt(y);
}
+ 3
Yes Armann
+ 3
thanks for help fra
+ 2
You're very welcome :)