<html>
<head>
<script language="javascript">
<!--
function showtime() {
var now_time = new Date();
var hours = now_time.getHours();
var minutes = now_time.getMinutes();
var secondes = now_time.getSeconds();
var timer = "" + ( (hours > 12) ? hours - 12 : hours);
timer += ((minutes > 10) ? ":" : ":0" ) + minutes;
timer += ((seconds > 10) ? ":" : ":0" ) + seconds;
timer += ((hours > 12) ? "pm" : "am");
document.clock.show.value = timer;
setTimeout("showtime()" ,1000);
}
-->
</script>
<meat http-equiv="content-type" content="text/html; charset=gb2312"/>
<title>....</title>
</head>
<body onLoad="showtime()">
<form name="clock" onSubmit="0">
<input type="text" name="show" size="10" style="background-color: lightyellow; border-width:3;">
</form>
</body>
</html>这段代码哪里有错呢,为什么我文本框类没有显示?

解决方案 »

  1.   

    var seconds = now_time.getSeconds();改成这样的
      

  2.   

    function showtime() {
    var now_time = new Date();
    var hours = now_time.getHours();
    var minutes = now_time.getMinutes();
    var seconds = now_time.getSeconds();
    var timer = "" + ( (hours > 12) ? hours - 12 : hours);
    timer += ((minutes > 10) ? ":" : ":0" ) + minutes;
    timer += ((seconds > 10) ? ":" : ":0" ) + seconds;
    timer += ((hours > 12) ? "pm" : "am");
    document.clock.show.value = timer;
    setTimeout("showtime()" ,1000);
    }