日期:2014-05-18  浏览次数:20370 次

asp.net中怎样在前台用js为html标签的文本框赋当前时间和当前时间的前三天的时间?
如题:现在界面上有两个<input type="text" id="txt1"> <input type="text" id="txt2">
当打开页面时我想为两个文本框赋当前时间和当前时间的前三天的初始值 请问该怎样实现?
麻烦高手们把代码帮忙写一下记住是前台不是后台!!! 谢谢

------解决方案--------------------
HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script>
function abc()
{
    var today=new Date();
    var otherDay=new Date(today.getTime()-259200000);
    document.getElementById("txt1").value=today.toLocaleString();
    document.getElementById("txt2").value=otherDay.toLocaleString();
}
</script>
</head>
<body onload="abc()">
<input type="text" id="txt1"/>
<input type="text" id="txt2"/>
</body>
</html>