simpleAutoComplete
Pessoal, to com problemas para colocar um autoCompletar para funcionar!!
Apos digitar o nome de um paciente o simpleAutoComplete esta retornando o seguinte:
>
. utf8_encode( $p ) .''."\n"; } echo '
'; } } } ?>
O Codigo:
index.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>simpleAutoComplete JQuery Plugin</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Language" content="pt-BR en">
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/simpleAutoComplete.js"></script>
<link rel="stylesheet" type="text/css" href="css/simpleAutoComplete.css" />
<script type="text/javascript">
$(document).ready(function(){
$('#nome_autocomplete').simpleAutoComplete('ajax_query.php',{
autoCompleteClassName: 'autocomplete',
selectedClassName: 'sel',
attrCallBack: 'rel',
identifier: 'nome'
},nomeCallback);
});
function nomeCallback( par ){
$("#datanascimento").val( par[0] );
$("#nome_mae").val( par[1] );
}
</script>
</head>
<body>
<div style="margin-left:100px;">
Nome:<input type="text" id="nome_autocomplete" name="nome" autocomplete="off" style="width: 250px; height: 23px;" /><br>
Nome Mãe:<input type="text" id="nome_mae" name="nome_mae" disabled /><br>
Data Nascimento: <input type="text" name="datanascimento" id="datanascimento" disabled />
</div>
</body>
</html>
ajax_query.php:
<?php
header('Content-type: text/html; charset=UTF-8');
$hostname = 'localhost';
$username = 'root';
$password = 'conpl763';
$dbname = 'pacientes';
mysql_connect( $hostname, $username, $password ) or die ( 'Erro ao tentar conectar ao banco de dados.' );
mysql_select_db( $dbname );
if( isset( $_REQUEST['nome'] ) && $_REQUEST['nome'] != "" )
{
$q = $_REQUEST['nome'];
if( isset( $_REQUEST['identifier'] ) && $_REQUEST['identifier'] == "nome")
{
$sql = "SELECT * FROM tb_paciente paciente where paciente.nome like '%".$q ."%' order by paciente.nome limit 10";
$r = mysql_query( $sql );
if ( $r )
{
echo '<ul>'."\n";
while( $l = mysql_fetch_array( $r ) )
{
$p = $l['nome'];
$p = preg_replace('/(' . $q . ')/i', '<span style="font-weight:bold;">$1</span>', $p);
echo "\t".'<li id="autocomplete_'.$l['datanascimento'].'" rel="'.$l['datanascimento'].'_' . $l['nome_mae'] . '">'. utf8_encode( $p ) .'</li>'."\n";
}
echo '</ul>';
}
}
}
?>
Alguem pode me ajudar???
Discussão (9)
Carregando comentários...