Ver Mensaje Individual
  #1 (permalink)  
Antiguo 01/08/2016, 17:07
Gustavo1973
 
Fecha de Ingreso: abril-2007
Ubicación: Merlo
Mensajes: 314
Antigüedad: 17 años
Puntos: 3
autocompletar con value en input text

tengo el siguiente codigo de un autocompletar con javascript
Código HTML:
Ver original
  1. <html lang="en">
  2.     <meta charset="utf-8">
  3.     <meta name="viewport" content="width=device-width, initial-scale=1">
  4.     <link rel="stylesheet" href="//code.jquery.com/ui/1.12.0/themes/base/jquery-ui.css">
  5.     <link rel="stylesheet" href="/resources/demos/style.css">
  6.     <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  7.     <script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script>
  8.     <script>
  9.     $( function() {
  10.         var availableTags = [
  11.             <?php
  12.             echo "\"Merlo, Buenos aires\",\"Merlo, San Luis\",\"Moreno, Buenos Aires\",\"San Antonio de Padua\""
  13.             ?>
  14.         ];
  15.         $( "#tags" ).autocomplete({
  16.             source: availableTags
  17.         });
  18.     } );
  19.     </script>
  20. </head>
  21.  
  22. <div class="ui-widget">
  23.     <label for="tags">Tags: </label>
  24.     <form method="POST" action="buscar.php">
  25.     <input type="text" name="buscar" id="tags">
  26.     <input type="submit">
  27.     </form>
  28. </div>
  29.  
  30.  
  31. </body>
  32. </html>
Funciona, pero quiero cargar también el value del input text, así a buscar.php me llega el id de la ciudad y no el nombre, ya que esto en realidad lo estaría cargando de una base de datos.
Como puedo modificar el javascript para que haga esto???
Desde ya muchas gracias!!!