Click to See Complete Forum and Search --> : Problem with parseInt


vinodjnair
07-10-2003, 02:13 AM
Hi

I got problem with parseInt function in javascript. parseInt works fine with digits 0-7 but when it is passed 8 or 9 it returns 0.

To solve this problem just pass the second parameter with the function which represents whether the first parameter to be converted to a octal,hexadecimal or decimal number.

Solution :

instead of using parseInt("8") or parseInt("9") use
parseInt("8",10) or parseInt("9",10) which will convert the first parameter to decimal integer :)