Click to See Complete Forum and Search --> : how to get clock in select field


zuzupus
06-30-2003, 03:45 AM
hi,
how to get clock on select field as i m always getting empty value is it possible to get value of clock inside this selct or i have to change this code please let me know and when i select some time let say 08:00 then it disappears how to avoid this

<form name="Tick">
<select name="Clock" size="1">
<option value="08:00">08:00</option>
<option value="09:00">09:00</option>
<option value="10:00">10:00</option>
<option value="11:00">11:00</option>
</select>
</form>
<script>


function show(){
var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()

if (hours<=9)
hours="0"+ hours
if (minutes<=9)
minutes="0"+minutes
document.Tick.Clock.value=hours+":"+minutes

setTimeout("show()",1000)
}
show()

</script>

thanks

steelersfan88
06-30-2003, 01:47 PM
<form name="Tick2">
<input type="hidden" name="Clock2">
</form>

<script>

function show2(){
if (!document.layers && !document.all) return;
if (document.layers) {
document.layers.pendule.document.write("<form name=\"Tick\"><select name=\"Clock\" size=\"1\"><option value=\"- - - -\" selected>"+ document.Tick2.Clock2.value +"</option><option value=\"09:00\">09:00</option><option value=\"10:00\">10:00</option><option value=\"11:00\">11:00</option></select></form>");
document.layers.pendule.document.close();
}
else if (document.all)
{
pendule.innerHTML = "<form name=\"Tick\"><select name=\"Clock\" size=\"1\"><option value=\"- - - -\" selected>"+ document.Tick2.Clock2.value +"</option><option value=\"09:00\">09:00</option><option value=\"10:00\">10:00</option><option value=\"11:00\">11:00</option></select></form>"
}
setTimeout("show2()",5000)
}

function show(){
var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
if (hours<=9)
hours="0"+ hours
if (hours>=13)
hours= eval(hours-12)
if (minutes<=9)
minutes="0"+minutes
document.Tick2.Clock2.value = ""+ hours +":"+ minutes +""
setTimeout("show()",1000)
}

</script>

<span id="pendule"></span>
<body onload="show();show2();">

I think this is the code you'll need to use. Hope it works.

This will update the time every ten seconds as opposed to every second to give users a chance to click the arrow. I'm not sure what other choices you want if you want every hour to appear. Write back if you need anything else.

Also, I did add a second form, Clock2 and a hidden field Tick2 which are required to read the time. the script transfers the time into the original form, which lies inside the span object.

(NOTE: This script includes a span object which can be placed anywhere on the screen by adding the code into the <span> tag: style="position:absolute;left:[pixels from left];top:[pixels from top]")

zuzupus
07-01-2003, 02:30 AM
hi,

thank you very much for your awesome feedback but the only problem is that when user selects the time it will be there in field not refreshing clock after every 10 sec. the idea behind this is i created one save button in form and tracking employee time on project suppose he forget the time to select then clock comes in picture and let say today he worked more hours but in the mean time he went for lunch also so next day he can come and select the time,not like refreshing every secs. hope u understood my position.

once he select the time it will display in field else clock value

thanks

zuzupus
07-01-2003, 06:57 AM
is it possible to get clock value in row from the script above instead of writing document.write(<form name=) is it possible to write something liek this
<tr>
<input type="text" size="1" name="clock">
</tr>