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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Im going NUTS! (parseint)

Status
Not open for further replies.

JohnSwe

Programmer
Feb 20, 2001
14
SE
function populate_dates()
{
var arryear = inputform.arryear[inputform.arryear.selectedIndex].value;
document.write(parseint(arryear)+1)
}

I get the fabolous object expected error when trying to use parseint! Whats wrong? Ive tried it in a 100 ways and i get the same error? How is this possible?!?!?!
 
SPECIFY THE RADIX
i won't post again and again the explanations, perform a search using "parseint" as a keyword or directly go to devedge or msdn and read the parseint part
basically, you HAVE TO write parseint((arryear+1), 10)
because if arryear is say "07" then (as the 1st number is 0) parseint will try to pasrse in OCTAL radix - 10 is NOT the default radix !!!!
 
Well that aint the problem...

the problem is that none of the functions work..

parseint, parsefloat, abs, tolowercase...

trying to use any of theese generates an "object expected" error... what is wrong?

 
ah ! so the problem is that arryear is not defined !!!!!!
checking ALL variables to see if their value is the expected one is one of the 1st thing to do when trying to debug - did you try to debug ??
can you find out by yourself why arryear isn't defined ??? it's easy, you should !!!
...
oooook here's the point :
var arryear = inputform.arryear.options[inputform.arryear.selectedIndex].value;



 
Well it is defined.. :)

Even if i write: var a = parseinte("55") i get the same "object expected" error...

Crazy huh?
 
Ok!


I got it....

i wrote "parseint" ... obviously javascript is CASE sensitive so it has to be parseInt to be recognized...

That is kind of stupid... :)



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top