首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

asp.net中怎样在前台用js为html标签的文本框赋当前时间和当前时间的前三天的时间?解决方法

2012-03-24 
asp.net中怎样在前台用js为html标签的文本框赋当前时间和当前时间的前三天的时间?如题:现在界面上有两个i

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> 

热点排行