需要大家的帮助,一个显示时间的问题!
我要做一个文本框,然后获取时间,按上下午的表示方式显示,可是总有错误,大家帮我看看!代码如下:<html>
<title>显示时间</title>
<head>
<script language="javascript">
var time=new Date();
with(time)
{
h=getHours();
if(h<=12)
{document.myform.text1.value="h+":"+getMinutes()+":"+getSeconds()+"AM""};
if(h>12&&h<=24)
{h=24-getHours();
document.myform.text1.value="h+":"+getMinutes()+":"+getSeconds()+"PM""};
if(h>24)
(alert("请输入正确的时间!"));
}
</script>
</head>
<body>
<form name=myform>
<b>现在时间为:</b>
<input name="text1" value="">
</body>
</html>