Ver Mensaje Individual
  #4 (permalink)  
Antiguo 08/07/2013, 16:36
diego quinteros
 
Fecha de Ingreso: octubre-2006
Ubicación: The Far West, Buenos Aires
Mensajes: 262
Antigüedad: 17 años, 6 meses
Puntos: 28
Respuesta: Doble Input: búsqueda instantánea Ajax

@alberto510a Genial!!!

Funcionó.

Por las dudas, si a alguien le sirve:

HTML:

Código HTML:
Ver original
  1. <p><b>Start typing a name in the input field below:</b></p>
  2. <form>
  3.     Ingrese su busqueda:
  4.     <input type="text" id="singleton" onKeyUp="var a = document.getElementById('id_select').value; showHint(this.value, a);">
  5.     <select name="users" id="id_select" onChange="var b = document.getElementById('singleton').value; showHint( b, this.value);">
  6.         <option value="">Seleccioná Supermercado:</option>
  7.         <option value="1">Carrefour</option>
  8.         <option value="2">Cooperativa Obrera</option>
  9.         <option value="3">Coto</option>
  10.         <option value="4">Disco</option>
  11.         <option value="5">Jumbo</option>
  12.         <option value="6">La Anónima</option>
  13.         <option value="7">La Libertad</option>
  14.         <option value="8">Vea</option>
  15.         <option value="9">Walmart</option>
  16.     </select>
  17. </form>
  18.  
  19. <p><span id="txtHint"></span></p>

JAVASCRIPT:

Código Javascript:
Ver original
  1. <script>
  2. function showHint(str, ss){
  3.     if (str.length == 0) {
  4.       document.getElementById("txtHint").innerHTML="";
  5.       return;
  6.     }
  7.     if (ss.length == 0) {
  8.       document.getElementById("txtHint").innerHTML = "SELECCIONA Categoria";
  9.       return;
  10.     } else {
  11.       document.getElementById("txtHint").innerHTML = ss;
  12.     }
  13.    
  14.     if (window.XMLHttpRequest) {
  15.       xmlhttp = new XMLHttpRequest();
  16.     } else {
  17.       xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  18.     }
  19.    
  20.     xmlhttp.onreadystatechange = function() {
  21.         if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
  22.             document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
  23.           }
  24.     }
  25.    
  26.     xmlhttp.open("GET","new2.php?q=" + str + "&s=" + ss, true);
  27.     xmlhttp.send();
  28. }
  29.  
  30. </script>

Cualquier duda, pregunten...
El código anda de maravilla!