...

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



effpeetee
06-22-2009, 06: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">
<html>
<head>
<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)
}
</script>
</head>
<body >
<script type="text/javascript>
onLoad = "clock()"
</script>

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

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



this here aint doing anything. try this



<body onload="clock()">


so when the body loads, execute the clock function

effpeetee
06-22-2009, 07: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.

Frank

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

effpeetee
06-23-2009, 02: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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum