Ver Mensaje Individual
  #5 (permalink)  
Antiguo 22/03/2013, 08:44
Avatar de informacionsys
informacionsys
 
Fecha de Ingreso: mayo-2011
Ubicación: Bogota D.C
Mensajes: 793
Antigüedad: 12 años, 11 meses
Puntos: 76
Respuesta: Lista dinamica

ok

entonces lo que necesitas es enviar una peticion al servidor por Ajax cada vez que se escriba en el input, enviandole obviamente el valor del input y hacer una consulta con un LIKE , y retornar los resultados en tabla html,

te hice un ejemplo

index.html


Código HTML:
Ver original
  1.     <title></title>
  2.  
  3.     <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
  4.  
  5.     <script type="text/javascript">
  6.     $(function()
  7.     {
  8.         $(".txt-valor-search").keyup(function()
  9.         {  
  10.             if ($(this).val() != "")
  11.               BuscarUsuario(this)
  12.         });
  13.  
  14.         function BuscarUsuario(e)
  15.         {
  16.             $.post('datos.php',{valorsearch:$(e).val()},function(respuesta)
  17.             {
  18.                 $(".info-result-usuarios").html(respuesta);
  19.             })
  20.         }
  21.     });
  22.     </script>
  23.  
  24. </head>
  25.  
  26. <div style="float:left;width:100%">
  27.     Buscar usuarios: <input type="text" id="valorsearch" class="txt-valor-search">
  28. </div>
  29. <div style="float:left;width:100%" class="info-result-usuarios"></div>
  30. </body>
  31. </html>

datos.php

Código PHP:
Ver original
  1. <?php
  2. EXTRACT($_REQUEST);
  3. $arreglo[] = array("documento"=>"57","name"=>"Paola");
  4. $arreglo[] = array("documento"=>"54","name"=>"Camilo");
  5. $arreglo[] = array("documento"=>"55","name"=>"Messi");
  6. $arreglo[] = array("documento"=>"58","name"=>"Alejandra");
  7.  
  8. $coincidencias = array();
  9. foreach($arreglo as $datos)
  10. {  
  11.         if(strstr($datos["name"],$valorsearch))
  12.         {
  13.             $coincidencias[] = $datos;
  14.         }
  15.    
  16. }
  17. ?>
  18. <table border="0" style="border:1px solid #c1cdcd;font-family:Calibri;border-collapse:separate">
  19.     <tr>
  20.         <td>Documento</td>
  21.         <td>Nombre usuario</td>
  22.     </tr>
  23.     <?php
  24.     foreach($coincidencias as $v)
  25.     {
  26.     ?>
  27.     <tr>
  28.         <td><?php echo $v["documento"];?></td>
  29.         <td><?php echo $v["name"];?></td>
  30.     </tr>  
  31.     <?php  
  32.     }
  33.     ?> 
  34. </table>

Última edición por informacionsys; 22/03/2013 a las 08:57