Ver Mensaje Individual
  #6 (permalink)  
Antiguo 30/10/2012, 13:38
Avatar de satjaen
satjaen
 
Fecha de Ingreso: septiembre-2012
Ubicación: Jaén (Andalucía)
Mensajes: 893
Antigüedad: 11 años, 8 meses
Puntos: 10
Respuesta: Recuperar datos de autocompletar en campos de texto independientes

Hola, estoy intentando hacer este autocompletar pero no se en que estoy fallando.

buscar.php

Código PHP:
<?php 

if(isset($_GET['numtelefono']) && $_GET['numtelefono'] !="")
{
require_once(
'Connections/conexion.php'); 

$sql="select telefono from usuarios whrere telefono like '".$_GET['numtelefono']."%'";

mysql_query($sql,$miconexion) or die (mysql_error());

while (
$fila=mysql_fetch_assoc($resultado))

echo 
"<li>".$fila['telefono']."</li>\n";

}

?>

index.php

Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
script language="javascript" src="js_menu/jquery.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Documento sin título</title>
<script language="javascript">
$(document).ready(function()
{
$("#telefono").keyup(function()
{
   $.get('buscar.php' ,{ numtelefono: $("#telefono").val() }, function(datos)
   {
       if (datos!="")
       
          $("#zonaresultado").addClass("zonaconborde");
          else
           $("#zonaresultado").removeClass("zonaconborde");
           
           $("#zonaresultado").html(datos);
       
   },"txt");
});
}); // JavaScript Document
</script>
<style>
.enlace_sugerencia_over{
    background-color: #3366CC;
}

div.zonaconborde{
    
 margin-top:5px;
 margin-left:165px;
 width:153px;
 background-color:#FFFFFF;
 text-aling: left;
 border: 1px solid #000000;
}

li{
    list-style:none;    
}

body{
    background-color:#CF9;
    
    }
#telefono{
    font-size:12px;
    font-style:italic;
    
    }    
</style>
</head>
<body>
<td width="9%"><input name="telefono" id="telefono" type="text" size="9" /></td>
<div id="zonaresultado"></div>
</body>
</html> 
Gracias