i'm trying to make simple clock but i cant get it to work. Can anyone help me out?
<html>
<head>
<script language="JavaScript">
var timerID = null;
var timerRunning = false;
function stopClock() {
if(timerRunning)
clearTimeout (timerID)
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
timerID = 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 timerID = null;
var timerRunning = false;
function stopClock() {
if(timerRunning)
clearTimeout (timerID)
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
timerID = 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>