Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

List box with time intervals as its options

 
Sree Mami
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.)
 
Sree Mami
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like a job for two nested for loops to me - one for the hours, one for the minutes.
 
Sree Mami
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic