PDA

View Full Version : java math



kink
01-10-2005, 08:53 PM
I have a javascript function that collects a number from a user input. Trouble is the function keeps treating the input like text instead of a numeric input.
anybody know the fix?

Chroder
03-12-2005, 06:19 PM
Javascript treats input as strings, so thats why it treating it as a string ;)

You can convert strings to integers/floats with the parseInt and parseFloat functions, respectively.


var mystring = "100.98"; // "100.98"
var myint = parseInt(mystring); // 100
var myfloat = parseFloat(mystring); // 100.98

gyhkcx
09-22-2005, 07:48 AM
you can use EVAL(mystring) also for that matter :)