wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes List box with time intervals as its options Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "List box with time intervals as its options" Watch "List box with time intervals as its options" New topic
Author

List box with time intervals as its options

Sree Mami
Ranch Hand

Joined: Jul 13, 2006
Posts: 75
Hi all!

In my project I have to design a form such that the List item in the form will have time intervals starting from 00:00HRS to 23:55HRS as its options with an interval of every 5 minutes. I am confused how to do it. Searched so many sites but didn't get an answer. Can anyone help me out how I can do this using JSP's.

Please reply soon as I am in urgent need of it...

marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Wouldn't this just be HTML form input? Something like...

If you're looking for something more than this, please provide additional information. (I would move this to the HTML forum, but I'm not sure I understand what you're asking.)


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Sree Mami
Ranch Hand

Joined: Jul 13, 2006
Posts: 75
Hi Marc

U are right! I have to do the same. But inserting so many options into a list box is too tedious so can u tell me any easy way to achieve it..

Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Sounds like a job for two nested for loops to me - one for the hours, one for the minutes.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Sree Mami
Ranch Hand

Joined: Jul 13, 2006
Posts: 75
Can anyone give me an idea how to achieve this task using JSP. I tried using two for loops but I am not getting
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Sree Mami:
Can anyone give me an idea how to achieve this task using JSP. I tried using two for loops but I am not getting

What exactly have you tried?

(Are you sure you want a single list of 288 options? Or might it be better to have a list of 24 options for the hour, and a separate list of 12 options for the minutes? My guess is that most users would be annoyed by that long list.)
Sree Mami
Ranch Hand

Joined: Jul 13, 2006
Posts: 75
Hi Marc

Actually I need to have those options showing every 5 minutes interval as some processing in our project are dealt even considering minutes for a specific task. Anyways I succeded in doing that.

My code is:

<select name="starttime" accesskey="R" tabindex="9" style="width:90"><option></option>
<%
int shr=0,smin=0;
for(shr=0;shr<24;shr++)
{
if(shr<24)
{
for(smin=0;smin<=60; )
{
if(smin==60)
{smin=0;break;}
if(shr<12)
time=shr+":"+smin+"AM";
else
time=shr+":"+smin+"PM";

System.out.println(time);
%>
<option value='<%=time%>'><%=time%><%
smin=smin+5;
}
}
}
%></option>
</select>

Any modifications to this code is appreciated...

Thank u
[ July 17, 2006: Message edited by: Sree Mami ]
Sree Mami
Ranch Hand

Joined: Jul 13, 2006
Posts: 75
Happy to see the response of Ilja Preuss and I really got how to deal with my task easily, otherwise I am totally confused thinking what to do!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: List box with time intervals as its options