

<html>
<head>
<title>带开关的动态时钟</title>
<script language="javascript">
<!--
function showClock() {
d = new Date();
hours = d.getHours();
minutes = d.getMinutes();
seconds = d.getSeconds();
clck = (hours >= 12) ? "下午" : "上午";
hours = (hours > 12) ? hours-12 : hours;
hours = (hours < 10) ? "0"+hours : hours;
minutes = (minutes < 10) ? "0"+minutes : minutes;
seconds = (seconds < 10) ? "0"+seconds : seconds;
time = clck + " " + hours + ":" + minutes + ":" + seconds;
var frm = document.form1;
if(frm.rap[0].checked) {
frm.disp.value = "";
} else {
frm.disp.value = time;
}
setTimeout("showClock()", 1000);
}
//-->
</script>
</head>
<body onload="showClock()">
<form name="form1">
<input type="text" name="disp" value="" size="30"><br>
关<input type="radio" name="rap" checked>
开<input type="radio" name="rap" >
</form>
</body>
</html>
关的情况
开的情况