Ver Mensaje Individual
  #4 (permalink)  
Antiguo 20/09/2012, 08:44
Avatar de totti026
totti026
 
Fecha de Ingreso: junio-2011
Mensajes: 150
Antigüedad: 12 años, 10 meses
Puntos: 4
Pregunta Respuesta: pasar variable de php en funcion javascript

Muchas gracias por su atencion... bueno pues estoy ocupando el jQuery Autocomplete plugin 1.1
dejo el codigo por si me pueden ayudar.

PHP Donde tengo mi formulario, ahi recojo la variable que quiero mandar..."$id"
Código PHP:
Ver original
  1. <?php
  2. $id=$_GET['id'];
  3. ?>
  4. <html>
  5. <head>
  6. <script type="text/javascript" src="js/jquery.js"></script>
  7. <script type='text/javascript' src='js/jquery.autocomplete.js'></script>
  8. <script type="text/javascript">
  9. $().ready(function() {
  10.     $("#proyecto").autocomplete("pagina.php", {
  11.         size: 65,
  12.         matchContains: true,
  13.         //mustMatch: true,
  14.         //minChars: 0,
  15.         //multiple: true,
  16.         //highlight: false,
  17.         //multipleSeparator: ",",
  18.         selectFirst: false
  19.     });
  20. });
  21. </script>
  22. </head>
  23. <body>
  24. <form>
  25. <input type="text" name="proyecto" id="proyecto" size=65>
  26. </form>
  27. </body>
  28. </html>

Este es otro archivo php donde quiero recoger la variable para usarla en una consulta.
Código PHP:
Ver original
  1. <?php
  2. include('conexion.php');
  3. $id=$_GET['id']; //AQUI RECOGERLA
  4. $q = strtolower($_GET["q"]);
  5. if (!$q) return;
  6.  
  7. $sql = "SELECT DISTINCT proyecto, ... FROM table WHERE proyecto='$id' ....";
  8. $rsd = mysql_query($sql);
  9. while($rs = mysql_fetch_array($rsd)) {
  10.     $resul = $rs['proyecto'];
  11.     echo "$resul\n";   
  12. }
  13. ?>

aca dejo el enlace del archivo js ya que es muy largo para postearlo...
http://crbcentral.com/js/jquery.autocomplete.js