1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
| <html>
<head>
<title>liste client</title>
<script type='text/javascript'>
function SearchList(htmlselect,htmltext,caseSensitive){
this.select=htmlselect;
this.text=htmltext;
this.allOptions=new Array();
for(i=0;i<this.select.options.length;i++){
this.allOptions[i]=this.select.options[i];
}
this.caseSensitive=false;
if(caseSensitive)
this.caseSensitive=true;
}
/* **********************
* Vide le contenu de la liste
*****************************/
SearchList.prototype.viderListe=function(){
var length=this.select.options.length;
for(i=length-1;i>=0;i--){
this.select.options[i]=null;
}
}
/* *********************************************
* Restore le contenu de la liste avec les valeurs initiales
******************************************************/
SearchList.prototype.restoreListe=function(){
for(i=0;i<this.select.options.length;i++){
this.select.options[i]=null;
}
for(i=0;i<this.allOptions.length;i++){
this.select.options[i]=this.allOptions[i];
}
}
/* **************************************
* Met à jour le contenu de la liste en fonction
* du texte saisi dans le champ
******************************************/
SearchList.prototype.MAJList=function(){
var search=this.text.value;
if(search=="" || search.length < 1){
this.restoreListe();
return;
}
else{
this.viderListe();
for(i=0;i<this.allOptions.length;i++){
if(!this.caseSensitive){
if(this.allOptions[i].text.toUpperCase().indexOf(search.toUpperCase())==0)
this.select.options[this.select.options.length]=this.allOptions[i];
}
else{
if(this.allOptions[i].text.indexOf(search)==0)
this.select.options[this.select.options.length]=this.allOptions[i];
}
}
}
}
</script>
</head>
<body>
<form>
<center>
<fieldset style="width: 350px" style="height:600px"style="font-size:26">
<legend>liste client</legend><br>
<label> Nom, Prénom :</label><br>
<SELECT id ='client' size="20" style="font-size:18" style="width: 300px">
<option value='-1'>Aucun</option>
<?php
mysql_connect("localhost","root","")
or die("Mysql connect error");
mysql_select_db("reservation");
$res = mysql_query("SELECT numero_client, nom_client, prenom_client FROM client")
or die ('Erreur sql!'.$res.'<br/>'.mysql_error());
while($row = mysql_fetch_assoc($res)) {
echo "<option value='".$row["numero_client"]."'>".$row["nom_client"]."   ".$row["prenom_client"]."</option>";
}
?>
</SELECT>
<br><br><label>Recherche : </label>  
<INPUT id = 'recherche' TYPE='text' NAME='recherche1' SIZE=30 MAXLENGTH=50 onKeyUp='ListeClient.MAJList();'>
<?php
echo "<script>var ListeClient = new SearchList(document.getElementById('client'), document.getElementById('recherche'),false );</script>\n";
?>
</fieldset>
</form>
</body>
</html> |
Partager