wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes problem with html variable inside jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "problem with html variable inside jsp" Watch "problem with html variable inside jsp" New topic
Author

problem with html variable inside jsp

Akshay Madhuranath
Greenhorn

Joined: Nov 29, 2009
Posts: 20
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

Joined: Apr 10, 2010
Posts: 308
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



Bye,
Nicola
Akshay Madhuranath
Greenhorn

Joined: Nov 29, 2009
Posts: 20
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

Joined: Nov 24, 2005
Posts: 14687
    
  16

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.


[My Blog]
All roads lead to JavaRanch
Akshay Madhuranath
Greenhorn

Joined: Nov 29, 2009
Posts: 20
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem with html variable inside jsp