现在的位置: 首页 > 综合 > 正文

让输入框默认时间为今天

2013年10月05日 ⁄ 综合 ⁄ 共 383字 ⁄ 字号 评论关闭
<html>
<head>
<script language="JavaScript"><!-- 
function time_rota()  //写当前日期的函数 
{ 
    var now = new Date(); 
    var h = now.getFullYear(); 
    var m = (now.getMonth() + 1>9) ? now.getMonth() + 1 : "0"+(now.getMonth() + 1); 
    var s = (now.getDate()>9)  ? now.getDate()  : "0"+now.getDate(); 
    document.form1.Today.value = h+"年"+m+"月"+s+"日"; 
} 
//--></script>
	</head>

<body onload="time_rota()"> 

<form name=form1> 
<input name=Today> 
</form>
</body>
</html>

抱歉!评论已关闭.