목표 달성: 두 개의 날짜, 드롭다운 상자 포함: 코드 복사 코드는 다음과 같습니다. < ;head> //jquery 주소 가져오기 > <BR>//startYear 변경<BR>functionchangeYear(str,isstart) <BR>{ <BR>var pre = "start" <BR>if(isstart == false ) <BR>{ <BR>pre = "end"; <BR>} <BR>var startMonth = $(pre "Month").value <BR>if(startMonth == "") <BR>{ <BR>var e = $(pre "월"); <BR>optionClear(e); <BR>} <BR>var n = MonHead[startMonth - 1]; (startMonth = = 2 && IsPinYear($(pre "연도").value)) <BR>{ <BR>n <BR>} <BR>writeDay(n,pre) <BR>} <BR>함수 changeMonth(str ,isstart) <BR>{ <BR>var pre = "start"; <BR>if(isstart == false) <BR>{ <BR>pre = "end"; var year = $(pre "연도").value; <BR>if(year == "") <BR>{ <BR>var e = $(pre "일") <BR>optionClear(e); <BR> return; <BR>} <BR>var n = MonHead[str - 1] <BR>if(str == 2 && IsPinYear($(pre "연도"))) <BR>{ <BR> n ; <BR>} <BR>writeDay(n,pre); <BR>} <BR>function dateStart() <BR>{ <BR>var defaultStartY = "2011"; ; <BR>var defaultStartD = "14"; <BR>var defaultEndM = "2" <BR>MonHead = [31,28 ,31, 30,31,30,31,31,30,31,30,31]; <BR>var prestr = new Array("start","end") <BR>for(var j=0; j<2 ; j ) <BR>{ <BR>var pre = prestr[j]; <BR>//시작 연도<BR>var y = new Date().getFullYear() <BR>if(pre = = "start ") <BR>{ <BR>//초기 선택 10일 전 시작 <BR>var i_index = 0 <BR>for(var i=(y-10); i<=y; i ) <BR> { <BR>$(pre "Year").options.add(new Option("" i "",i)) <BR>if(i == defaultStartY) <BR>{ <BR>$ (pre " 연도").options[i_index].selected = true; <BR>} <BR>i_index ; <BR>} <BR>} <BR>else <BR>{ <BR>var i_index =0; 🎜>for (var i=(y-5); i<=y 5; i ) <BR>{ <BR>$(pre "연도").options.add(new Option("" i "",i )); <BR>if(i == defaultEndY) <BR>{ <BR>$(pre "연도").options[i_index].selected = true; <BR> } <BR>//월 시작<BR>defaultM = (pre == "start" ? defaultStartM : defaultEndM) <BR>for(var i = 1; i < 13; i ) <BR>{ <BR>$ (pre "Month").options.add(new Option("" i "",i)) <BR>if(i == defaultM) <BR>{ <BR>$(pre "Month" ).options [i-1].selected = true; <BR>} <BR>} <BR>//시작일<BR>var n = MonHead[$(pre "Month").value]; if(new Date().getMonth == 1 && IsPinYear($(pre "연도").value)) <BR>{ <BR>n ; <BR>} <BR>defaultD = (pre == "start" ? defaultStartD : defaultEndD) <BR>writeDay(n,pre); <BR>$(pre "Day").options[defaultD-1].selected = true <BR>} <BR>} <BR>function writeDay (n, pre) <BR>{ <BR>var e = $(pre "Day") <BR>optionClear(e) <BR>for (var i=1; i<(n 1); i ) <BR> { <BR>e.options.add(new Option("" i "",i)) <BR>} <BR>} <BR>function IsPinYear(연도) <BR>{ <BR>return (0 = = 연도%4 && (연도 0 != 0 || 연도 % 4 == 0)) <BR>} <BR>function optionClear(e) <BR>{ <BR>for(var i=e .options .length; i>=0; i-) <BR>{ <BR>e.remove(i) <BR>} <BR>} <BR> head> From 연도 월 일 연도 월 日 몇 가지 코드를 참고했으니 좋겠습니다. 도움이 필요한 친구들에게 유용할 것입니다.