View Full Version : Resolved Why does this supplied code not work?

06-22-2009, 07:53 PM
I have put this code together from a tuition site, but I cannot get it to work.
Some of the instructions were ambiguous so I may have done it wrong.(the story of my life.) :eek: Any help gratefully received.:D

Frank alias effpeetee.

<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<script type="text/javascript">
function clock(){
var time = new Date()
var hr = time.getHours()
var min = time.getMinutes()
var sec = time.getSeconds()
if(hr < 10){
hr = " " + hr
if(min < 10){
min = "0" + min
if(sec < 10){
sec = "0" + sec
document.clock.digits.value = hr + ":" + min + ":" + sec
setTimeout("clock()", 1000)
<body >
<script type="text/javascript>
onLoad = "clock()"

<FORM name="clock">
<FONT face="Courier New,Courier" size=4>
<INPUT type="text" name="digits"
size=8 maxlength=8 value="Loading">

06-22-2009, 07:57 PM
<script type="text/javascript>
onLoad = "clock()"

this here aint doing anything. try this

<body onload="clock()">

so when the body loads, execute the clock function

06-22-2009, 08:07 PM
Thanks mike182uk,

I thought that was probably one of the parts I did not quite understand. Your modification works perfectly. Many thanks.
Up until now, I have been a cut and paste (pinch someone elses code) man.
I am trying to come to terms with javascript.

Back to the grindstone.


06-22-2009, 08:21 PM
We all have to start somewhere :-)

06-23-2009, 03:07 PM
We all have to start somewhere :-)
I am 84 yrs old in September.
Perhaps I have left it a bit late.

but -

Nil desperandum.

Nothing ventured, nothing gained.

Frank - alias effpeetee