日期和星期联动
我有这样一个 日期文本框
<input name= "dn_date " onfocus= "calendar() " width= "100 " value= " <%=date()%> " size= "10 " />
还有一个星期 <input type= "text " size=10 name= "dn_week "> 文本框
如果选择一个日期 在星期文本框里自动显示 星期数 谢谢大家
------解决方案-------------------- <html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title> 新建网页 2 </title>
<script>
function a(){
var curdate=new Date();
document.all.date1.value=curdate.getFullYear()+ "- "+(curdate.getMonth()+1)+ "- "+curdate.getDate();
document.all.week.value=curdate.getDay();
}
function b(){
var dateStr= "2007-7-24 ";
var dateArr=dateStr.split( "- ");
var nextDate=new Date(dateArr[0],dateArr[1]-1,dateArr[2]);
document.all.date1.value=nextDate.getFullYear()+ "- "+(nextDate.getMonth()+1)+ "- "+nextDate.getDate();
document.all.week.value=nextDate.getDay();
}
function c(){
var dateStr=document.all.date1.value;
var dateArr=dateStr.split( "- ");
var nextDate=new Date(dateArr[0],dateArr[1]-1,dateArr[2]);
document.all.date1.value=nextDate.getFullYear()+ "- "+(nextDate.getMonth()+1)+ "- "+nextDate.getDate();
document.all.week.value=nextDate.getDay();
}
</script>
</head>
<body onload= "a() ">
日期: <input type=text id=date1 value= " " onchange= "c() ">
星期: <input type=text id=week value= " ">
<input type=button onclick= "b() " value= "下一天 ">
</body>
</html>
------解决方案--------------------http://www.blogjava.net/mxx/archive/2006/09/27/72159.html