java math

kinkkink serious memberVPS - Virtual Prince of the Server
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?

Comments

  • ChroderChroder Senior Member The Royal RAM
    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
    
  • gyhkcxgyhkcx Beginner Link Clerk
    you can use EVAL(mystring) also for that matter :)
Sign In or Register to comment.