Ver Mensaje Individual
  #1 (permalink)  
Antiguo 20/03/2006, 12:50
Avatar de Chuty
Chuty
 
Fecha de Ingreso: noviembre-2002
Ubicación: el bar de la esquina
Mensajes: 609
Antigüedad: 23 años, 10 meses
Puntos: 2
Filtro sobre Select

Hola a Todos, andaba buscando un filtro sobre un select y encontre este ejemplo en los FAQS ahora me pregunto si se podría hacer que tambien funcione inversamente o sea que al seleccionar del select se carge con un valor el input, espero haberme explicado bien.

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

   var 
i; 

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

   function 
cambia(oCntrl){ 
    var 
txtVal = document.frm.txt.value; 
    while(
oCntrl.length > 0) oCntrl.options[0]=null; 
    
i = 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> 

Me interesaria que funcione de ambas maneras.

Desde ya muchas gracias y saludos a todos