-
SitePoint Enthusiast
simple addition using integers stored in variables...not working
Hi All,
this must be really simple but i cant get it to work and it seems so simple that i cant find any website on why this doesnt work for me.
so i have this simple function...
function update(value, oldvalue)
{
var a = value;
var b = oldvalue;
var result = a + b;
document.form.fieldname.value=result;
}
and call the function using a field with this...
onkeyup="update(this.value, other)"
But all its doing is concatenating the 2 numbers together as though they are strings!!!
so if this.value = 11
and other = 15
it displays 1115
i want to add them and display the total, do i need to specify them as being integers or something?
Any help would be greatly appreciated!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks