Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

string to integer?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
what's the function to change a string variable with only numberic expression to a integer variable?
 
Try parseInt()

parseInt(s)
parseInt(s, radix)

arguments:
s = The String to be passed.
radix = An optional integer argument that represents the radix (i.e., base) of the number to be passed.

For more information refer to "Javascript - The Definitive Guide" page 643 in the 3rd edition.

 
You would use the function: Number()

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!--
v = &quot;32&quot;;
document.write(v + 1 + &quot;<BR>&quot;); // Ouputs 321
document.write(Number(v) + 1 + &quot;<BR>&quot;); // Outputs 33
//-->
</SCRIPT> - tleish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top