Ver Mensaje Individual
  #2 (permalink)  
Antiguo 03/05/2012, 14:07
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

algo asi ?

no entiendo la ultima frase:
Cita:
como puedo hacer para que si el usuario elige por ejemplo "5", en el segundo select los campos de options solo lleguen hasta 10
debería ser 5 ?? o 10 ?

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(select) {
  7.     var segundoSelect = document.getElementById("segundo-select");
  8.  
  9.     segundoSelect.options.length = 0;
  10.     var total = parseInt(select.value);
  11.     for (var i= 1; i <= total ; i++) {
  12.         var option = new Option(i, i);
  13.         segundoSelect.options.add(option);
  14.     }
  15. }
  16. </head>
  17.     <select onchange="javascript:onChangeSelect(this);">
  18.         <option value="">seleccionar</option>
  19.         <option value="1">1</option>
  20.         <option value="10">10</option>
  21.         <option value="20">20</option>
  22.     </select>
  23.    
  24.     <select id="segundo-select">
  25.     </select>
  26. </body>
  27. </html>
__________________
Hazle un favor a tu cerebro y juega Ajedrez online
Chess online