請教關于日期函數的問題
function window_onload()
{
?? ?var myForm = document.form1;
?? ?var nowDate = new Date();
?? ?myForm.firstDay.options[nowDate.getDate()-1].selected = true;
?? ?myForm.secondDay.options[nowDate.getDate()-1].selected =true;
??? myForm.secondMonth.options[nowDate.getMonth()].selected =true;
?? ?myForm.firstMonth.options[nowDate.getMonth()].selected = true;
?? ?myForm.firstYear.options[nowDate.getFullYear()-1970].selected =true;
?? ?myForm.secondYear.options[nowDate.getFullYear()-1970].selected =true;
}
//可以執行,返回firstDay,secondDay.options【】對象的值為當前時間,,
function window_onload()
{
?? ?var myForm = document.form1;
?? ?var nowDate = new Date();
?? ?myForm.firstDay.options[nowDate.getDate()-1].selected = true;
?? ?myForm.firstMonth.options[nowDate.getMonth()].selected = true;
?? ?myForm.firstYear.options[nowDate.getFullYear()-1970].selected =true;
?? ?myForm.secondDay.options[nowDate.getDate()-1].selected =true;
?? ?myForm.secondMonth.options[nowDate.getMonth()].selected =true;?? ?
?? ?myForm.secondYear.options[nowDate.getFullYear()-1970].selected =true;
}
順序更改后,firstDay 正常返回當前日期,secondDay則無法返回當前日期,為什么???
2015-12-28
給一下你的完整代碼看一下,包括html結構