Ver Mensaje Individual
  #14 (permalink)  
Antiguo 16/07/2010, 05:38
Avatar de _cronos2
_cronos2
Colaborador
 
Fecha de Ingreso: junio-2010
Mensajes: 2.062
Antigüedad: 13 años, 10 meses
Puntos: 310
Respuesta: Ayuda con Formulario

Se puede hacer así, pero a mí me gusta más de otra manera.
Por ejemplo:
Código Javascript:
Ver original
  1. <script type='text/javascript'>
  2. function selects(){
  3. nada = '- - - Esperando selección - - -';
  4. futbol = new Array('Madrid', 'Barça');
  5. basket = new Array('Chicago Bulls', 'Bucks');
  6. voley = new Array('Voley internacional', 'Voley nacional');
  7. primero = document.getElementById('selecc');
  8. segundo = document.getElementById('selecc2');
  9.  switch(primero.value){
  10.   case '-':
  11.    segundo.length = 1
  12.    segundo.options[0].value = '-';
  13.    segundo.options[0].text = nada;
  14.    segundo.disabled = true;
  15.   break;
  16.   case 'futbol':
  17.    segundo.length = futbol.length;
  18.    for(i = 0; i<futbol.length; i++){
  19.     segundo.options[i].value = futbol[i];
  20.     segundo.options[i].text = futbol[i];
  21.    }
  22.   break;
  23.   case 'basket':
  24.    segundo.length = basket.length;
  25.    for(i = 0; i<basket.length; i++){
  26.     segundo.options[i].value = basket[i];
  27.     segundo.options[i].text = basket[i];
  28.    }
  29.   break;
  30.   case 'voley':
  31.    segundo.length = voley.length;
  32.    for(i = 0; i<voley.length; i++){
  33.     segundo.options[i].value = voley[i];
  34.     segundo.options[i].text = voley[i];
  35.    }
  36.   break;
  37.  }
  38.  if(primero.selectedIndex!=0){
  39.   segundo.disabled = false;
  40.  }
  41. }
  42. </script>
Y en el HTML:
Código HTML:
Ver original
  1. <form name='a1' action='' method="post">
  2. <select id='selecc' onchange='selects();'>
  3. <option value='-' selected='selected'>-Seleccione...-</option>
  4. <option value='futbol'>Fútbol</option>
  5. <option value='basket'>Baloncesto</option>
  6. <option value='voley'>Voleibol</option>
  7. <select id='selecc2' disabled='disabled'>
  8. <option value='-'>- - - Esperando selección - - -</option>
  9. </form>

Saludos (: