/ Published in: JavaScript
Javascript sometimes confuses strings and numbers. When this happens, you get bizarre outcomes such as "2 + 2 = 22". The following code FORCES a conversion to a number.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
var myval = Number(document.myform.mytext.value); //var myval = document.myform.myval.value; myval++; myval--;