Código:
Código HTML:<html> <head> <title>Adquisiciones de Metodologia de la Investigación</title> <script language="JavaScript"> var a="Dia,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28"; var b="Dia,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29"; var c="Dia,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30"; var d="Dia,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31"; var e="Mes,01,02,03,04,05,06,07,08,09,10,11,12"; var f="Año,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013"; var mydate=new Date(); var year=mydate.getFullYear(); // full en vez de normal, el normal está en desuso var dia=getDay(); var mes=getMonth(); if (dia<10){dia="0"+dia;} if (mes<10){mes="0"+mes;} //if (year < 1000){year+=1900;} function addOpt(oCtrl, iPs, sTt, sVl){ var sOpcion=new Option(sTt, sVl); oCtrl.options[iPs]=sOpcion; return sOpcion; } function esBisiesto(nAno){ var bRes = true; res = bRes && (nAno % 4 == 0); res = bRes && (nAno % 100 != 0); res = bRes || (nAno % 400 == 0); return bRes; } function inicializar(){ ele = esBisiesto(year) ? b : a; ele=ele.split(","); oCtrl=document.getElementById('days1'); while (oCtrl.length) oCtrl.remove(0); for (var i=0;i<ele.length;i++){ var nueva_opcion = addOpt(oCtrl, i, ele[i], ele[i]); if(ele[i]==dia){nueva_opcion.selected = true;} } //meses ele=e.split(","); oCtrl=document.getElementById('months1'); while (oCtrl.length) oCtrl.remove(0); for (var i=0;i<ele.length;i++){ var nueva_opcion = addOpt(oCtrl, i, ele[i], i); if( (i-1)==mes ){nueva_opcion.selected = true;} } ele=f.split(","); oCtrl=document.getElementById('years1'); while (oCtrl.length) oCtrl.remove(0); for (var i=0;i<ele.length;i++){ var nueva_opcion = addOpt(oCtrl, i, ele[i], ele[i]); if(ele[i]==year){nueva_opcion.selected = true;} } ele = esBisiesto(year) ? b : a; ele=ele.split(","); oCtrl=document.getElementById('days'); while (oCtrl.length) oCtrl.remove(0); for (var i=0;i<ele.length;i++){ var nueva_opcion = addOpt(oCtrl, i, ele[i], ele[i]); if(ele[i]==dia){nueva_opcion.selected = true;} } //meses ele=e.split(","); oCtrl=document.getElementById('months'); while (oCtrl.length) oCtrl.remove(0); for (var i=0;i<ele.length;i++){ var nueva_opcion = addOpt(oCtrl, i, ele[i], i); if( (i-1)==mes ){nueva_opcion.selected = true;} } ele=f.split(","); oCtrl=document.getElementById('years'); while (oCtrl.length) oCtrl.remove(0); for (var i=0;i<ele.length;i++){ var nueva_opcion = addOpt(oCtrl, i, ele[i], ele[i]); if(ele[i]==year){nueva_opcion.selected = true;} } } function Cambia(oCtrl) { var qmes, i=document.getElementById('months').selectedIndex; switch (i) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: qmes=d; break; case 4: case 6: case 9: case 11: qmes=c; break; case 2: qmes=esBisiesto(year)? b : a; break; default: qmes=false; } if( qmes ) { while (oCtrl.length) oCtrl.remove(0); ele=qmes.split(","); for(i=0;i<ele.length;i++) { addOpt(oCtrl, i, ele[i], ele[i]); } } } function Cambia1(oCtrl) { var qmes, i=document.getElementById('months1').selectedIndex; switch (i) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: qmes=d; break; case 4: case 6: case 9: case 11: qmes=c; break; case 2: qmes=esBisiesto(year)? b : a; break; default: qmes=false; } if( qmes ) { while (oCtrl.length) oCtrl.remove(0); ele=qmes.split(","); for(i=0;i<ele.length;i++) { addOpt(oCtrl, i, ele[i], ele[i]); } } } function poner(a,eta,ete,eto){ ja=document.getElementById(a); jb=document.getElementById(eta); jc=document.getElementById(ete); jd=document.getElementById(eto); switch(a){ case "id6": { if (jc.value <7) {ja.value=jb.value+"01";} else{ if (jc.value <13) {ja.value=jb.value+"02";} } // alert(ja.value); break;} case "dates": {ja.value=jb.value+"/"+jc.value+"/"+jd.value; // alert(ja.value); break;} }} function poner1(a,eta,ete,eto){ ja=document.getElementById(a); jb=document.getElementById(eta); jc=document.getElementById(ete); jd=document.getElementById(eto); switch(a){ case "id61": { if (jc.value <7) {ja.value=jb.value+"01";} else{ if (jc.value <13) {ja.value=jb.value+"02";} } // alert(ja.value); break;} case "dates1": {ja.value=jb.value+"/"+jc.value+"/"+jd.value; // alert(ja.value); break;} }} function validacion() { x = document.getElementById("months").selectedIndex; y = document.getElementById("days").selectedIndex; if(x==0 || y==0){ alert('Porfavor seleccione la fecha'); return false; } w = document.getElementById("months1").selectedIndex; z = document.getElementById("days1").selectedIndex; if(w==0 || z==0){ alert('Porfavor seleccione la fecha'); return false; } } </script> </head> <body> <fieldset style="width:800" align="center"> <br> <br> <script type="text/javascript">document.onload=setTimeout("inicializar()", 0000);</script> <table border='0' align="center"> <form action='adq_metodologia.php' method='post' onSubmit="return validacion()"> <tr ><td colspan="11" align="center"><h2>Adquisiciones de Metodología</h2></td></tr> <tr><td><p class="texto">Ingrese fecha :</p></td><td><select id="years" name="years" class="CLASE" ></select></td><td> <select id="months" name="months" class="CLASE" onBlur="poner('id6','years','months',0)" onChange="Cambia(document.getElementById('days'))" ></select></td> <td><select id="days" name="days" class="CLASE" onChange="poner('dates','years','months','days')"></select></td><td><p class="texto">hasta</p></td> <td><select id="years1" name="years1" class="CLASE"></select></td><td> <select id="months1" name="months1" class="CLASE" onBlur="poner1('id61','years1','months1',0)" onChange="Cambia1(document.getElementById('days1'))"></select></td> <td><select id="days1" name="days1" class="CLASE" onChange="poner1('dates1','years1','months1','days1')"></select></td> <th><input id="dates1" name="dates1" type="hidden" /></th> <th><input id="dates" name="dates" type="hidden" /></th> <td><input type="submit" value="consultar" class="CLASE" /></td></tr> </form> </table> </body> </html>