function LengthOfMonth(Y, M){ with (new Date(Y,M,1,12)){ setDate(0); return getDate(); } } var D_Opt = new Array() function datuminit(){ var inputs=document.getElementsByTagName("input"); for(i=0;i= DiM ) NsI = DiM-1 for (K=Dol; K >DiM ; K--){ D_Opt[K] = Dy.options[K-1] ; Dy.options[K-1] = null } for (K=Dol+1 ; K<=DiM ; K++) Dy.options[K-1] = D_Opt[K] Dy.selectedIndex = NsI document.getElementById(id).value=Yr.options[Yr.selectedIndex].text+"-" + (Mo.selectedIndex+1-1) + "-" +(Dy.selectedIndex+1-1); } hoselect.onchange=function() { this.className="changed"; idt=this.id.split('_'); idt=idt.splice(0,idt.length-1); id=idt.join("_"); Yr=document.getElementById(id+"_ev"); Mo=document.getElementById(id+"_ho"); Dy=document.getElementById(id+"_nap"); DiM = LengthOfMonth(+Yr.options[Yr.selectedIndex].text, Mo.selectedIndex+1-1)+1 Dol = Dy.options.length if ( (NsI = Dy.selectedIndex) >= DiM ) NsI = DiM-1 for (K=Dol ; K >DiM ; K--){ D_Opt[K] = Dy.options[K-1] ; Dy.options[K-1] = null } for (K=Dol+1 ; K<=DiM ; K++) Dy.options[K-1] = D_Opt[K] Dy.selectedIndex = NsI document.getElementById(id).value=Yr.options[Yr.selectedIndex].text+"-" + (Mo.selectedIndex+1-1) + "-" + (Dy.selectedIndex+1-1); } napselect.onchange=function() { this.className="changed"; idt=this.id.split('_'); idt=idt.splice(0,idt.length-1); id=idt.join("_"); Yr=document.getElementById(id+"_ev"); Mo=document.getElementById(id+"_ho"); Dy=document.getElementById(id+"_nap"); document.getElementById(id).value=Yr.options[Yr.selectedIndex].text+"-" + (Mo.selectedIndex+1-1) + "-" + (Dy.selectedIndex+1-1); } base = new Date().getFullYear(); mon3 = ["jan.", "febr.", "márc.", "ápr.", "máj.", "jún.", "júl.", "aug.", "szept.", "okt.", "nov.", "dec."] evselect.options[0]=new Option ("év",0); hoselect.options[0]=new Option ("hónap",0); napselect.options[0]=new Option ("nap",0); tol=parseInt(input.getAttribute("alt")); ig=parseInt(input.getAttribute("title")); if(tol==0 || isNaN(tol))tol=2010; if(ig==0 || isNaN(ig))ig=2011; for (j=1; j<=ig-tol+1; j++) evselect.options[j] = new Option(tol+j-1) for (j=1; j<=12 ; j++) hoselect.options[j] = new Option(mon3[j-1]) for (j=1; j<=31 ; j++){ if(j+1-1<10) nap="0"+(j+1-1); else nap=(j+1-1); napselect.options[j] = new Option(nap) } input.parentNode.appendChild(evselect); input.parentNode.appendChild(hoselect); input.parentNode.appendChild(napselect); if(input.value!=""){ datumt=input.value.split("-"); evselect.selectedIndex=datumt[0]-tol+1; hoselect.selectedIndex=datumt[1]-1+1; napselect.selectedIndex=datumt[2]-1+1; Yr=evselect; Mo=hoselect; Dy=napselect; DiM = LengthOfMonth(+Yr.options[Yr.selectedIndex].text, Mo.selectedIndex+1-1)+1 Dol = Dy.options.length if ( (NsI = Dy.selectedIndex) >= DiM ) NsI = DiM-1 for (K=Dol ; K >DiM ; K--){ D_Opt[K] = Dy.options[K-1] ; Dy.options[K-1] = null } for (K=Dol+1 ; K<=DiM ; K++) Dy.options[K-1] = D_Opt[K] Dy.selectedIndex = NsI // alert(adatum[0]); } } } } addEvent(window, 'load', datuminit);