• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem with html variable inside jsp

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..








 
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic