Introduction:-
This is my second tutorial and I will show you how to get the Time in a Text Box.. perhaps in a Text Box it will be useless, but it could be used in other instances!
Solution:-
This code goes in the <head> tags:-
And this code as the body code:-Code:<script language="JavaScript"> var timerID = null; var timerRunning = false; function stopclock (){ if(timerRunning) clearTimeout(timerID); timerRunning = false; } function showtime () { var now = new Date(); var hours = now.getHours(); var minutes = now.getMinutes(); var seconds = now.getSeconds() var timeValue = hours timeValue += ((minutes < 10) ? ":0" : ":") + minutes timeValue += ((seconds < 10) ? ":0" : ":") + seconds document.clock.face.value = timeValue; timerID = setTimeout("showtime()",1000); timerRunning = true; } function startclock () { stopclock(); showtime(); } </script>
Explanation:-Code:<body onLoad="startclock()"> <form name="clock" onSubmit="0"> <div align="center"><center><p><input type="text" name="face" size="10" value> </p> </center></div> </form>
I think its simple without any need of explanation.. but if you have any suggestions/questions just post them here
A Preview:-
Conclusion:-
As Always Feedback is welcome and the full source is attached!!
Last edited by Jaan; 03-09-2008 at 08:09 AM.
Nice, and I am now looking for an Analog clock now. Hope I can find it by Google. I will search tomorrow.
Thanks for the code. very useful. Text Box clock idea is good, and pretty simple code.
http://forum.codecall.net/javascript...log-clock.html
I found this one for you!
Seems Tcm9669 continuously digging on JavaScript mats. Nice work and thanks
Thanks for it lol. Nice I will add it as an html mod into a Joomla powered website I'm currently working on.
good script
There are currently 2 users browsing this thread. (0 members and 2 guests)
Bookmarks