Thursday, September 01, 2005

Javascript parseInt - Convert string to integer

Sometimes you want to convert from one type of variable to another. JavaScript is pretty loose in its variable types. However, certain situations require certain variables. There are a few functions available to help you convert from one form to another.
parseIntparseInt() will convert a string to an integer. The format is:
parseInt( string [,radix] )

Example:
parseInt(“10”);
parseInt(document.form.text1.value);

No comments: