Ver Mensaje Individual
  #60 (permalink)  
Antiguo 11/12/2002, 11:52
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
60.- Filtro sobre un select

P: ¿Como puedo filtrar los elementos que conforman un select de acuerdo a lo tipeado en un área de texto?

R: [ver ejemplo]

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

   var 
i;

   function 
addOpt(oCntrlsTxtsValsCnd){
    if (
sTxt.substr(0sCnd.length).toUpperCase() == sCnd.toUpperCase()){
     var 
selOpcion=new Option(sTxtsVal);
     eval(
oCntrl.options[i++]=selOpcion);
    }
   }

   function 
cambia(oCntrl){
    var 
txtVal document.frm.txt.value;
    while(
oCntrl.length 0oCntrl.options[0]=null;
    
0;
    
oCntrl.clear;
    
addOpt(oCntrl,  "Ciudad de México""0"txtVal);
    
addOpt(oCntrl,  "Ciudad de Panamá""0"txtVal);
    
addOpt(oCntrl,  "Ciudad de Guatemala""0"txtVal);
    
addOpt(oCntrl,  "Caracas""0"txtVal);
    
addOpt(oCntrl,  "Cancún""0"txtVal);
    
addOpt(oCntrl,  "Maracay""0"txtVal);
    
addOpt(oCntrl,  "Maracaibo""0"txtVal);
    
addOpt(oCntrl,  "Zaragoza""0"txtVal);
   }
  
</script>
 </head>
 <body onload="cambia(document.frm.ciudad)">
  <form name="frm">
   <table border="0">
    <tr>
     <td>
      Ciudad:
     </td>
     <td>
      <input type="text" name="txt" onkeyup="cambia(document.frm.ciudad)">
     </td>
     <td>
      <select name="ciudad">
      </select>
     </td>
    </tr>
   </table>
  </form>
 </body>
</html> 

Última edición por Kaopectate; 17/06/2003 a las 18:25