Ver Mensaje Individual
  #4 (permalink)  
Antiguo 03/05/2012, 15:54
chinanzio
 
Fecha de Ingreso: marzo-2007
Mensajes: 82
Antigüedad: 17 años, 2 meses
Puntos: 21
Respuesta: como cambiar options en un select en un formlario

esto te sirve ?

Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  4. <title>Insert title here</title>
  5. <script type="text/javascript">
  6. function onChangeSelect(selectQueCambioElUsuario) {
  7.     var primerSelect = document.getElementById("primer-select");
  8.     var segundoSelect = document.getElementById("segundo-select");
  9.  
  10.     var selectQueHayQueCambiarleLosOptions = selectQueCambioElUsuario == primerSelect ?  segundoSelect : primerSelect;
  11.     var totalaOcultar = parseInt(selectQueCambioElUsuario.value);
  12.     var length = selectQueHayQueCambiarleLosOptions.length;
  13.     for (var i = 0; i < length; i++) {
  14.         var optionaOcultar = selectQueHayQueCambiarleLosOptions.options[i];
  15.         var displayStr = (i < length - totalaOcultar) ? "" : "none";
  16.         optionaOcultar.style.display = displayStr;
  17.     }
  18. }
  19. </head>
  20.     <select id="primer-select" onchange="javascript:onChangeSelect(this);">
  21.         <option value="0">0</option>
  22.         <option value="1">1</option>
  23.         <option value="2">2</option>
  24.         <option value="3">3</option>
  25.         <option value="4">4</option>
  26.         <option value="5">5</option>
  27.     </select>
  28.  
  29.     <select id="segundo-select" onchange="javascript:onChangeSelect(this);">
  30.         <option value="0">0</option>
  31.         <option value="1">1</option>
  32.         <option value="2">2</option>
  33.         <option value="3">3</option>
  34.         <option value="4">4</option>
  35.         <option value="5">5</option>
  36.     </select>
  37. </body>
  38. </html>

es lo que entendí, que a lo mejor lo entendí mal, la cosa es que se ocultan la cantidad de opciones del otro select que se selccionan en un select :P jeje
__________________
Hazle un favor a tu cerebro y juega Ajedrez online
Chess online