View Full Version : How to display Time in Select-Option Selector

12-15-2007, 12:15 PM
How to display Time in Select-Option Selector ?

To explain more clearly, i would like to give an example:

When we open the Calendar in the Windows computer from bottom right hand corner of the computer screen.

We get a window in which, we can see Date & Time Zone.

Now the TIme function which is shown allows us to change the Hour, Minutes,Second onSelect of individual Field..?

Thats what i am trying to implement using JSP?

Philip M
12-15-2007, 01:21 PM

12-15-2007, 01:39 PM
Thank you for reply Philip, i have gone through those Examples , however i was able to only change the Hour of the Time displayed in the text box.

Q1. I want to change the Hours, Minutes and Seconds onSelecting fields
Q2. And Program it shows id=myspan has been passed to the script, I want to display the time in the text box, however its also showing me in Body?

Philip M
12-15-2007, 05:32 PM
Could you explain what is the point of what you are trying to do?

The time is taken from the user's operating system. As such any arbitrary time can be displayed if there is any purpose in it. I can see why you might want to change the hour depending on the time-zone, but I find it hard to see the point of altering minutes/seconds.

12-17-2007, 08:03 AM
Sorry Philip, Couldn't reply over the weekend..

We are implementing the time on a webpage, we thought to provide user friendly, so that User can easily modify the time on Select of, Hours, Minutes and Seconds and Click on Plus or Minus button to increas or decrease the same...

Q. I tried to implement what the code shows in the above link, however the Time showing on a webpage body, i was unable to remove, Since myspan has been used inthe script..

What we want is only to show the time in the text box and alter from there?

Philip M
12-17-2007, 09:11 AM
I am afraid that I still do not see the point.

But you can display the time (taken from the host clock) thus:-

<body onload = "initClock()">
<form name = "myform">
<input type ="text" name = "clockDisplay" size = "6">

<script type = "text/javascript">

function initClock() {
var now = new Date();
var hh = now.getHours();
var mm = now.getMinutes();
var ss = now.getSeconds();
if (hh <10) {hh = "0" + hh}
if (mm <10) {mm = "0" + mm}
if (ss <10) {ss = "0" + ss}
document.myform.clockDisplay.value = hh + ":" + mm + ":" + ss;


But if the user is to alter this time (why??) you will need to check that the new time is valid (not 34:88:94 or whatever).