Código:
<table width="90%" border="1" align="center" cellpadding="2" cellspacing="0"> <tr align="center"> <td colspan="2"><label onclick="fncPeriodoM();">Mensual</label></td> <td colspan="2"><label onclick="fncPeriodoT();">Trimestral</label></td> <td width="19%" colspan="2"><label onclick="fncPeriodoS();">Semestral</label></td> <td colspan="2"><label onclick="fncPeriodoA();">Anual</label></td> <td width="15%"><label onclick="fncPeriodoP();">Personalizado</label></td> </tr> <tr> <td width="6%" align="center"><label onclick="anterior('m');"><<</label></td> <td width="9%" align="center"><label onclick="siguiente('m');">>></label></td> <td width="21%" align="center"><label onclick="anterior('t');"><<</label></td> <td width="15%" align="center"><label onclick="siguiente('t');">>></label></td> <td align="center"><label onclick="anteriorS();"><<</label></td> <td align="center"><label onclick="siguienteS();">>></label></td> <td width="8%" align="center"><label onclick="anterior('a');"> << </label></td> <td width="7%" align="center"><label onclick="siguiente('a');"> >> </label></td> <td> </td> </tr> <tr> <td colspan="9" align="center">Desde <input type="text" name="Desde" id="Desde" /> Hasta <input type="text" name="Hasta" id="Hasta" /></td> </tr> </table>
AQUI EL JS
Código:
el problema esta en que en periodo trimestral me resta bien el valor de "Desde" pero el hasta lo deja igual, me gustaria que se fuera restanto cada tres meses tambien...y la otra es...como puedo hacer para poder pasar los parametros al boton siguientes y anterior parano repetir codigo var Fecha = new Date(); var Ano = Fecha.getFullYear(); var Mes = (Fecha.getMonth()+ 1); //PERIODO MENSUAL function fncPeriodoM() { Desde.value = "1/" + Mes + "/" + Ano; if (Mes == "1" | Mes == "3" | Mes == "5" | Mes == "7" | Mes == "8" | Mes == "10" | Mes == "12") {Hasta.value = "31/" + Mes + "/" + Ano;} else if (Mes == "2") {Hasta.value = "28/" + Mes + "/" + Ano;} else {Hasta.value = "30/" + Mes + "/" + Ano; } } //PERIODO TRIMESTRAL function fncPeriodoT() { if(Mes == "1" | Mes == "2" | Mes == "3") {Desde.value = "1/" + "1" +"/" + Ano;} if (Mes == "1" | Mes == "2" | Mes == "3") {Hasta.value = "31/" + "3" +"/" + Ano;} if(Mes == "4" | Mes == "5" | Mes == "6") {Desde.value = "1/" + "4" +"/" + Ano;} if (Mes == "4" | Mes == "5" | Mes == "6") {Hasta.value = "30/" + "6" +"/" + Ano;} if(Mes == "7" | Mes == "8" | Mes == "9") {Desde.value = "1/" + "7" +"/" + Ano;} if (Mes == "7" | Mes == "8" | Mes == "9") {Hasta.value = "30/" + "9" +"/" + Ano;} if(Mes == "10" | Mes == "11" | Mes == "12") {Desde.value = "1/" + "10" +"/" + Ano;} else (Mes == "10" | Mes == "11" | Mes == "12") {Hasta.value = "31/" + "12" +"/" + Ano;} } //PERIODO SEMESTRAL function fncPeriodoS() { if(Mes == "1" | Mes == "2" | Mes == "3" | Mes == "4" | Mes == "5" | Mes == "6") {Desde.value = "1/" + "6" +"/" + Ano;} if (Mes == "1" | Mes == "2" | Mes == "3" | Mes == "4" | Mes == "5" | Mes == "6") {Hasta.value = "30/" + "6" +"/" + Ano;} if(Mes == "7" | Mes == "8" | Mes == "9" | Mes == "10" | Mes == "11" | Mes == "12") {Desde.value = "1/" + "7" +"/" + Ano;} else (Mes == "7" | Mes == "8" | Mes == "9" | Mes == "10" | Mes == "11" | Mes == "12") {Hasta.value = "31/" + "12" +"/" + Ano;} } //PERIODO ANUAL function fncPeriodoA() { Desde.value= "1/" + "1/" + Ano; {Hasta.value = "31/" + "12" + "/" + Ano;} } //PERIODO PERSONALIZADO function fncPeriodoP() { Desde.value = "/" + Mes + "/" + Ano; if (Mes == "1" | Mes == "3" | Mes == "5" | Mes == "7" | Mes == "8" | Mes == "10" | Mes == "12") {Hasta.value = " /" + Mes + "/" + Ano;} else if (Mes == "2") {Hasta.value = "28/" + Mes + "/" + Ano;} else {Hasta.value = "/" + Mes + "/" + Ano; } } //PAGINADOR PERIODO MENSUAL function anterior(m) { Mes = (parseInt(Mes) - 1); if (Mes == "0") { Mes = "12"; Ano = Ano - 1; } fncPeriodoM(); } function siguiente(m) { Mes = (parseInt(Mes) + 1); if (Mes == "13") { Mes = "1"; Ano = Ano + 1; } fncPeriodoM(); } //PAGINADOR PERIODO TRIMESTRAL function anterior(t) { Mes = (parseInt(Mes) - 3); if (Mes == "0") { Mes = "0"; } if(Mes > 12) { Mes = Mes -3; Ano = Ano - 1; } fncPeriodoT(); } function siguiente(t) { Mes = (parseInt(Mes) + 3); if (Mes < 12) { Mes = Mes + 3; Ano = Ano + 1; } fncPeriodoT(); } //PAGINADOR PERIODO SEMESTRAL function anteriorS() { Mes = (parseInt(Mes) - 6); if (Mes == "1") { Mes = Mes + 6; } fncPeriodoS(); } function siguienteS() { Mes = (parseInt(Mes) + 6); if (Mes = "12") fncPeriodoS(); } //PAGINADOR PERIODO ANUAL function anteriorA() { Ano = (parseInt(Ano) - 1); if (Ano == "0") { Ano = Ano + 1; } fncPeriodoA(); } function siguienteA() { Ano = (parseInt(Ano) + 1); if (Mes = "12") fncPeriodoA(); }