• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with html variable inside jsp

 
Akshay Madhuranath
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello guys,
I have a html page inside a jsp and im trying to populate it. ie i have time as below.


And similarly i have end time. Now im finding the difference between the start and end hour values and printing on the screen. The function is as below.

Simirlarly i've it for end time. and the difference function is as below.



Then i am printing the value inside the text box of html which's as follows.


so now everything works well except for 08 and 09 numbers. It will have the value but it will not return 0 when i try to print it using alert mess. So what might be the prob?? how to solve this? pleasehelp guys. Thanks in advance..








 
Nicola Garofalo
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hallo Akshay,
probably you will loose the leading zero with numbers from 00 to 09, not just for 08 and 09.
When you parseInt , you are in int domain, where 00 is number 0, 01 is number 1 and so on.
If you want to print the leading zero, add it artificially.

Anyway this is a html/javascript problem. Next time please post your problem in the appropriate forum. CarefullyChooseOneForum


 
Akshay Madhuranath
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nicola Garofalo wrote:Hallo Akshay,
probably you will loose the leading zero with numbers from 00 to 09, not just for 08 and 09.
When you parseInt , you are in int domain, where 00 is number 0, 01 is number 1 and so on.
If you want to print the leading zero, add it artificially.

Anyway this is a html/javascript problem. Next time please post your problem in the appropriate forum. CarefullyChooseOneForum




Yes yes sure. Next time i will see to it that i will post in the appropriate forum. Since it was jsp related question i posted here..
Yes what you said is true. But its only happening with 08 and 09. all other numbers work fine.. What might be the prob? I am trying to debug using netbeans. But i am not getting it.. Help me with this.. Thanks..
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the string begins with "0", it will be interpreted as an octal number. Remove the leading 0, or use parseInt(strTimeArray[0],10); instead.
 
Akshay Madhuranath
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Christophe Verré wrote:If the string begins with "0", it will be interpreted as an octal number. Remove the leading 0, or use parseInt(strTimeArray[0],10); instead.


Hey you solved my problem.. Thanks a lot..
Cheers,
Akshay.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic