Ver Mensaje Individual
  #4 (permalink)  
Antiguo 30/05/2009, 23:19
Avatar de sanchezg
sanchezg
 
Fecha de Ingreso: abril-2009
Mensajes: 76
Antigüedad: 15 años
Puntos: 0
Respuesta: 2onload que solo funcionan por separa2

hola pues primero muchissisimas gracias por responder pues ya lo probe y sigue =creo q es mi codigo y esq lo que que estoy haciendo es usar combos para fecha el problema es que necesito 3 fecha nacimiento, fechainicio y fechafin y en el javascript q saca esto solo le modifique el año,mes y dia por año1 2 y 3,mes1 2 y 3 y dia1 2 y3 la funcion llenaano y los case, todo lo demas lo deje = crees que sea eso? esta es la funcion gracias
este es el javascript...
<script language="JavaScript">

var aMeses = new Array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre")

function padNmb(nStr, nLen, sChr){
var sRes = String(nStr);
for (var i = 0; i < nLen - String(nStr).length; i++)
sRes = sChr + sRes;
return sRes;
}

function makeDateFormat(nDay, nMonth, nYear){
var sRes;
sRes = padNmb(nDay, 2, "0") + "/" + padNmb(nMonth, 2, "0") + "/" + padNmb(nYear, 4, "0");
return sRes;
}

function addOpt(oCntrl, iPos, sTxt, sVal){
var selOpcion = new Option(sTxt, sVal);
oCntrl.options.add(selOpcion, iPos);
}

function lastDayOfMonth(nMonth, nYear){
var aMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
if ((nMonth == 2) && (nYear % 4 == 0))
return 29;
else
return aMonth[nMonth - 1];
}

function cambia(nCambiado){
var nAno;
var nMes;
with (document.formulario){
nAno = parseInt(ano2.options[ano2.selectedIndex].value);
switch (nCambiado){
case 6:
llenaMes(mes2, nAno);
break;
case 7:
nMes = parseInt(mes2.options[mes2.selectedIndex].value);
llenaDia(dia2, nAno, nMes)
break;
case 8:
nMes = parseInt(mes2.options[mes2.selectedIndex].value);
nDia = parseInt(dia2.options[dia2.selectedIndex].value);
nacimiento.value = makeDateFormat(nDia, nMes + 1, nAno);
break;
}
}
}

function llenaAno2(oAno){
var hoy = new Date();
var ini = 1960;
addOpt(oAno, 0, "", "");
for (var i = ini; i <= hoy.getYear(); i++)
addOpt(oAno, i - ini + 1, String(i), String(i));
}

function llenaMes2(oMes, nAno){
var hoy = new Date();
var nFin = 11;
while (oMes.length > 0) oMes.remove(0);
if (nAno == hoy.getYear()) nFin = hoy.getMonth();
addOpt(oMes, 0, "", "");
for (var i = 0; i <= nFin; i++)
addOpt(oMes, i + 1, aMeses[i], String(i));
}

function llenaDia2(oDia, nAno, nMes){
var hoy = new Date();
var nFin = lastDayOfMonth(nMes + 1, nAno);
while (oDia.length > 0) oDia.remove(0);
if (nAno == hoy.getYear() && nMes == hoy.getMonth()) nFin = hoy.getDate();
addOpt(oDia, 0, "", "");
for (var i = 1; i <= nFin; i++)
addOpt(oDia, i + 1, String(i), String(i));
}

</script>
<script>function cargaralload(){
llenaAno(document.formulario.ano);
llenaAno1(document.formulario.ano1);
llenaAno2(document.formulario.ano2);
}
</script>