-
JS Help
Ok,
I have this code, which is meant to add something on to the value currently displayed.
Heres the code so far:
HTML Code:
function calc(hcs)
{
try{
var cur = document.getElementById("calcscreen").innerHTML;
cur = cur+hcs;
document.getElementById("calcscreen").innerHTML = cur;
}
catch(err)
{
alert(err);
}
}
function cls()
{
document.getElementById("calcscreen").innerHTML = 0;
}
Whats going wrong is that if we use the calc(2.0); function, if the initial display was 0 it would become
02
Then if we do again it would become
022
I think its making the variables string and as such, not adding correctly, if this is the case, does anyone have the code to turn them back into integer/single?
Thanks for any help =]
-
Sorry to double post,
But does anyone know a way to get round this error?