D
daniyal_rox
Guest
I'm trying to make a clock in html using JavaScript bu I cant get it working
<html>
<head>
<script language=“JavaScript”>
var timerlD = null;
var timerRunning = false;
function stopclock() {
if(timerRunning)
clearTimeout (timerlD)
timerRunning = false
}
function startclock() {
stopclock()
showtime()
}
function showtime(){
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
var timevalue = ““ + ((hours > 12) ? hours - 12 : hours);
timevalue += ((minutes < 10) ? “:0” : “:”) + minutes
timevalue += ((seconds < 10) ? “:0” : “:”) + seconds
timevalue += (hours >= 12) ? “ P.M.” : “A.M.”
document.clock.face.value = timeValue
timerlD = setTimeout(”showtime()” ,1000) timerRunning = true
}
</script></head>
<body onLoad=startclock() bgcolor=beige > <form name=clock onSubmit=0>
<input type=text name=face size=11 value=....Initializing...>
</form>
</body>
</html>
<html>
<head>
<script language=“JavaScript”>
var timerlD = null;
var timerRunning = false;
function stopclock() {
if(timerRunning)
clearTimeout (timerlD)
timerRunning = false
}
function startclock() {
stopclock()
showtime()
}
function showtime(){
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
var timevalue = ““ + ((hours > 12) ? hours - 12 : hours);
timevalue += ((minutes < 10) ? “:0” : “:”) + minutes
timevalue += ((seconds < 10) ? “:0” : “:”) + seconds
timevalue += (hours >= 12) ? “ P.M.” : “A.M.”
document.clock.face.value = timeValue
timerlD = setTimeout(”showtime()” ,1000) timerRunning = true
}
</script></head>
<body onLoad=startclock() bgcolor=beige > <form name=clock onSubmit=0>
<input type=text name=face size=11 value=....Initializing...>
</form>
</body>
</html>