Ver Mensaje Individual
  #11 (permalink)  
Antiguo 22/11/2011, 10:17
Avatar de Kaopectate
Kaopectate
Colaborador
 
Fecha de Ingreso: diciembre-2001
Ubicación: Curaçao (Antillas Holandesas)
Mensajes: 3.179
Antigüedad: 22 años, 4 meses
Puntos: 38
Respuesta: Selects dependientes

Eso es lo que creí haber hecho, solo que usando nómeros. Míralo con nombres:

Código PHP:
<html>
 <
head>
  <
script language='JavaScript'>

   var 
    
aNumeros = new Array('Enrique''Iván''Felipe''Camilo''Ernesto''Julio''Javier''Hernán');
    
aValores = new Array('Felipe''Julio''Javier''Iván');

   function 
addOption(oCntrliPossTxtsVal){
    var 
oOption = new Option(sTxtsVal);
    
oCntrl.options[iPos] = oOption;
   }

   function 
esValido(iControlnVal){
    var 
bRes true;
    for (var 
0aValores.lengthi++)
     if (
!= iControl)
      
bRes bRes && (aValores[i] != nVal);
    return 
bRes;
   }

   function 
preasigna(){
    for (var 
1<= 4i++){
     
oSel document.getElementById('s' i);
     while (
oSel.length)
      
oSel.remove(0);
     for (var 
00aNumeros.lengthj++){
      if (
esValido(1aNumeros[j]))
       
addOption(oSelp++, aNumeros[j], aNumeros[j]); 
     }
     
oSel.value aValores[1];
    }
   }

   function 
recalcula(oSelnSel){
    
aValores[nSel 1] = oSel.value;
    
preasigna();
   }

   function 
muestra(){
    
alert('s1=' document.getElementById('s1').value ' s2=' document.getElementById('s2').value ' s3=' document.getElementById('s3').value ' s4=' document.getElementById('s4').value);
   }

  
</script>
 </head>
 <body>
  <select id='s1' onchange='recalcula(this, 1)'></select>
  <select id='s2' onchange='recalcula(this, 2)'></select>
  <select id='s3' onchange='recalcula(this, 3)'></select>
  <select id='s4' onchange='recalcula(this, 4)'></select>
  <input type='button' value='show' onclick='muestra()'>
  <script language='JavaScript'>

   preasigna();

  </script>
 </body>
</html>