PDA

View Full Version : using parseInt() to change a concatenated string into a number



LFCFan
Mar 8th, 2007, 04:27 PM
Hi all,

I may be trying to swat a fly with a banjo here but I'm having some trouble turning a concatenated string into a number:

<script language = "javascript">

var chkSeqStrBuilder =""

function chkLength() //checks length of string inside the scrChanger input box
{
if (scrChanger.value.length ==2)
{
parseInt((chkSeqStrBuilder+=scrChanger.value))
alert(typeof(chkSeqStrBuilder)) //this always returns string even though its been parseInt'd
chkSeq()
}
}

Any ideas where I'm going wrong?

Cheers in advance
Joe

LFCFan
Mar 8th, 2007, 04:39 PM
Sorted it. Just have to multiply the string "200305" by 1.

Cheers
Joe

shyam
Mar 8th, 2007, 05:02 PM
generally u assign the result of a parseInt to something

chkSeqStrBuilder =
parseInt((chkSeqStrBuilder+=scrChanger.value))