View Full Version : java math
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 :)
Powered by vBulletin® Version 4.1.8 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.