function selectDate1(){ //2007年~現在の年まで表示 var year = 2007; var year2 = 2024; var month = 4; var date = 30; var intLoopCount = 0; var intLoopCount2 = 0; document.myform.year1.length = year2 - year + 2; document.myform.year1.options[ 0 ].text = ""; intLoopCount2 = 1; for( intLoopCount = year2 ; intLoopCount >= year ; intLoopCount -- ){ // 2007年から現在の年まで自動でoption追加 document.myform.year1.options[ intLoopCount2 ].text = intLoopCount; intLoopCount2++; } if( document.myform.year1.value == year2 ){ // 現在の年が選択されたとき document.myform.month1.length = month + 1; document.myform.month1.options[ 0 ].text = ""; for( intLoopCount = 1 ; intLoopCount <= month ; intLoopCount++ ){ document.myform.month1.options[ intLoopCount ].text = intLoopCount; } }else{ // 過去データのとき if( document.myform.year1.value == year ){ document.myform.month1.length = 10; document.myform.month1.options[ 0 ].text = ""; intLoopCount2 = 1 for( intLoopCount = 4 ; intLoopCount <= 12 ; intLoopCount++ ){ document.myform.month1.options[ intLoopCount2 ].text = intLoopCount; intLoopCount2++; } }else{ document.myform.month1.length = 13; document.myform.month1.options[ 0 ].text = ""; for( intLoopCount = 1 ; intLoopCount <= 12 ; intLoopCount++ ){ document.myform.month1.options[ intLoopCount ].text = intLoopCount; } } } if( document.myform.year1.value !== "" && document.myform.month1.value !== "" ){ date = leapYearCheck( document.myform.year1.value , document.myform.month1.value ) + 1; document.myform.date1.length = date document.myform.date1.options[ 0 ].text = ""; for( intLoopCount = 1 ; intLoopCount < date ; intLoopCount++ ){ document.myform.date1.options[ intLoopCount ].text = intLoopCount; } }else{ document.myform.date1.length = 32; document.myform.date1.options[ 0 ].text = ""; for( intLoopCount = 1 ; intLoopCount <= date ; intLoopCount++ ){ document.myform.date1.options[ intLoopCount ].text = intLoopCount; } } } function selectDate2(){ //2007年~現在の年まで表示 var year = 2007; var year2 = 2024; var month = 4; var date = 30; var intLoopCount = 0; var intLoopCount2 = 0; document.myform.year2.length = year2 - year + 2; document.myform.year2.options[ 0 ].text = ""; intLoopCount2 = 1; for( intLoopCount = year2 ; intLoopCount >= year ; intLoopCount -- ){ // 2007年から現在の年まで自動でoption追加 document.myform.year2.options[ intLoopCount2 ].text = intLoopCount; intLoopCount2++; } if( document.myform.year2.value == year2 ){ // 現在の年が選択されたとき document.myform.month2.length = month + 1; document.myform.month2.options[ 0 ].text = ""; for( intLoopCount = 1 ; intLoopCount <= month ; intLoopCount++ ){ document.myform.month2.options[ intLoopCount ].text = intLoopCount; } }else{ // 過去データのとき if( document.myform.year2.value == year ){ document.myform.month2.length = 10; document.myform.month2.options[ 0 ].text = ""; intLoopCount2 = 1 for( intLoopCount = 4 ; intLoopCount <= 12 ; intLoopCount++ ){ document.myform.month2.options[ intLoopCount2 ].text = intLoopCount; intLoopCount2++; } }else{ document.myform.month2.length = 13; document.myform.month2.options[ 0 ].text = ""; for( intLoopCount = 1 ; intLoopCount <= 12 ; intLoopCount++ ){ document.myform.month2.options[ intLoopCount ].text = intLoopCount; } } } if( document.myform.year2.value !== "" && document.myform.month2.value !== "" ){ date = leapYearCheck( document.myform.year2.value , document.myform.month2.value ) + 1; document.myform.date2.length = date document.myform.date2.options[ 0 ].text = ""; for( intLoopCount = 1 ; intLoopCount < date ; intLoopCount++ ){ document.myform.date2.options[ intLoopCount ].text = intLoopCount; } }else{ document.myform.date2.length = 32; document.myform.date2.options[ 0 ].text = ""; for( intLoopCount = 1 ; intLoopCount <= date ; intLoopCount++ ){ document.myform.date2.options[ intLoopCount ].text = intLoopCount; } } } function leapYearCheck( y , m ){ var year = 2024; var month = 4; var date = 29; var last = 0; var mDate = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) if( year == y && month == m ){ last = 29; }else if (2 == m && (0 == y % 400 || (0 == y % 4 && 0 != y % 100))) { last = 29; } else { last = mDate[m - 1]; } return last; }