Faire une recherche à partir d'un input et afficher information dans d'autres input
Bonjour ,
J'aimerai faire quelque chose de semblable à ce site http://www.codemashups.com/source/jq...tocomplete-p1/. Mais au lieu d'afficher dans un tableau moi c'Est sur plusieurs input. Je cherche un numéro de projet et il m'affiche le nom du client. Coté recherche et autocomplete pour mon champ projet c'est nickel. Me manque la partie apres avoir écrit le numéro de projet complet m'afficher en temps réel le nom du client. Je le fais en html, php base de donnée phpmyadmin avec requete sql ainsi que l'utilisation de javascript. J'ai fais des pages de test avant de l'inclure dans mon vrai site web. voici ma page autocomplete.php
Code:
1 2 3 4 5 6 7 8 9
| <html>
<head>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript"
src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>
<link rel="stylesheet" type="text/css"
href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" />
<script type="text/javascript"> |
Code:
1 2 3 4 5 6
| $(document).ready(function(){
$("#name").autocomplete({
source:'getautocomplete.php',
minLength:1
});
}); |
Code:
1 2 3 4 5 6 7 8 9 10 11
| </script>
</head>
<body>
<form method="post" action="">
<input type="text" id="name" name="name" />
</form>
<form method="post" action="">
<input type="text" id="client" name="client" />
</form>
</body>
<html> |
et voici ma page getautocomplete.php
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| $con = mysql_connect($host_name,$user_name,$pass_word) or die(mysql_error());
mysql_select_db($database_name, $con) or die(mysql_error());
$term=$_GET["term"];
$query=mysql_query("select * from projets where proNum like '%".$term."%' order by proNum");
$json=array();
while($student=mysql_fetch_array($query)){
$json[]=array(
'value'=> $student["proNum"],
'label'=>$student["proNum"]
);
}
echo json_encode($json);
?> |
Des solutions svp?