- HTML code
<input type="text" name="adddate" style="width:120px" readonly="readonly" />
上面的输入框 怎么能让他的默认值为一个星期以前的 求源码
------解决方案--------------------------------------------------------
- HTML code
<html><head><title>JavaScript计算日期10天前的日期</title><meta http-equiv="content-Type" content="text/html;charset=gb2312"></head><body><input type=text id="display" name="display" size=20 value=""></body></html><script language="JavaScript">function AddDays(DaysToAdd) { var now=new Date(); var newdate=new Date(); var newtimems=newdate.getTime()-(DaysToAdd*24*60*60*1000); newdate.setTime(newtimems); alert(newdate.toLocaleString()); return newdate.toLocaleString();}document.getElementById("display").value=AddDays(10);</script>