星期天是0 怎么改成7
<script>
function a(){
var curdate=new Date();
document.all.dn_date.value=curdate.getFullYear()+ "- "+(curdate.getMonth()+1)+ "- "+curdate.getDate();
document.all.dn_week.value=curdate.getDay();
}
function b(){
var dateStr=document.all.dn_date.value
var dateArr=dateStr.split( "- ");
var nextDate=new Date(dateArr[0],dateArr[1]-1,dateArr[2]);
document.all.dn_date.value=nextDate.getFullYear()+ "- "+(nextDate.getMonth()+1)+ "- "+nextDate.getDate();
document.all.dn_week.value=nextDate.getDay();
}
function c(){
var dateStr=document.all.dn_date.value;
var dateArr=dateStr.split( "- ");
var nextDate=new Date(dateArr[0],dateArr[1],dateArr[2]);
document.all.dn_date.value=nextDate.getFullYear()+ "- "+(nextDate.getMonth()+1)+ "- "+nextDate.getDate();
document.all.dn_week.value=nextDate.getDay();
}
</script>
<input name= "dn_date " onfocus= "calendar() " width= "100 " value= " <%=date()%> " size= "10 " onchange= "c() "/>
<input type= "text " size=10 name= "dn_week " onclick= "b() ">
代码如上
现在选择一个日期 比如应该是星期天的话 dn_week里显示的是0
请帮忙 谢谢
------解决方案--------------------function b(){
var dateStr=document.all.dn_date.value
var dateArr=dateStr.split( "- ");
var nextDate=new Date(dateArr[0],dateArr[1]-1,dateArr[2]);
document.all.dn_date.value=nextDate.getFullYear()+ "- "+(nextDate.getMonth()+1)+ "- "+nextDate.getDate();
document.all.dn_week.value=nextDate.getDay()==0?7:nextDate.getDay();
}