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

problem with parseInt function 2

Status
Not open for further replies.

MarcDePoe

Programmer
Dec 19, 2000
101
US
I have a form field with a date in it formatted mm/dd/yy.
The field is named LaunchDate, so the below code shows "7 - 9 - 07" for 05/07/01, "6 - 9 - 06" for 05/06/01, but shows "0 - 9 - 09" for 05/09/01! (also for 05/08/01)...
For some reason, 08 and 09 are evaluating to 0!?
It seems that only these two dates do this so I'm wondering if parseInt is at fault ...

note: #Day(now())# is a coldfusion function that yields the 9 in the above examples (today is the 9th)

alert(parseInt(ThisForm.LaunchDate.value.substring(3,5))+" - #Day(now())# - "+ThisForm.LaunchDate.value.substring(3,5));

Any light shed would be greatly appreciated,
- Marc
 
pass a second parameter to parseInt known as the radix, which specifies the base of the number system you want to use...make it base 10

parseInt(val,10)

because I think it is trying to use hex or oct because of the 0 at the front


might not work, but worth a try... jared@eae.net -
 
You are the man!
I've been pulling out my hair with this one.

Thanks a million,
- Marc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top