mickeymouse 0 Posted July 2, 2019 Report Share Posted July 2, 2019 I don't know why I am getting "011" instead of "2" after 2 times through my function. My code is: <input name=\"ent2a\" type='number' id=\"ent2a\" size=\"1\" style=\"text-align:center\" MaxLength=2 value=0 onblur=\"chkent(ent2a)\"> <input id='cntR' type='number' size='1' Â MaxLength=2 value=0> function chkent(entry) {with (entry); var e = entry.value; if(e==1){cntR.value = cntR.value + 1;return false;} return false;} Quote Link to post Share on other sites
Ingolme 1,019 Posted July 2, 2019 Report Share Posted July 2, 2019 Because the "+" operator concatenates strings as well as adding numbers. The computer determines which operation to do based on the data type of the variables. The value property of an HTML form control is always a string, so you have to convert it to a number before doing number operations on it. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.