Return to Snippet

Revision: 4608
at January 13, 2008 15:59 by darkphotn


Updated Code
var myval = Number(document.myform.mytext.value);

//var myval = document.myform.myval.value; myval++; myval--;

Revision: 4607
at January 13, 2008 15:58 by darkphotn


Updated Code
var myval = Number(document.myform.myval.value);

//var myval = document.myform.myval.value; myval++; myval--;

Revision: 4606
at January 13, 2008 13:19 by darkphotn


Initial Code
var myval = document.myform.myval.value; myval++; myval--;

Initial URL

                                

Initial Description
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.

Initial Title
Convert String to Number in Javascript

Initial Tags

                                

Initial Language
JavaScript