請教關(guān)于日期函數(shù)的問題
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;
}
//可以執(zhí)行,返回firstDay,secondDay.options【】對象的值為當(dāng)前時(shí)間,,
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 正常返回當(dāng)前日期,secondDay則無法返回當(dāng)前日期,為什么???
2015-12-28
給一下你的完整代碼看一下,包括html結(jié)構(gòu)