<SCRIPT LANGUAGE="JavaScript">
var Liste=new CreerListe("Client", 5, 265)
<? //Remplir la liste déroulante
while ($l_client = mysql_fetch_array($result_client))
{
?>
Liste.Add("<? echo $l_client["code_client"]." ".$l_client["libelle_client"] ?> ");
<?
}
?>
function CreerListe(nom, hauteur, largeur)
{
this.nom=nom; this.hauteur=hauteur; this.largeur=largeur;
this.search="";
this.nb=0;
this.Add=AjouterItem;
this.Afficher=AfficherListe;
this.MAJ=MAJListe;
}
function AjouterItem(item)
{
this[this.nb]=item
this.nb++;
}
SearchList.prototype.MAJinput=function()
{
this.text.value=this.select[this.select.selectedIndex].text;
}
function AfficherListe()
{
if (document.layers)
{
var Z="<SELECT name="+this.nom+" size="+this.hauteur+">";
}
else
{
var Z="<SELECT name="+this.nom+" style='width:"+this.largeur+"'>";
}
for (var i=0; i<this.nb; i++)
{
Z+="<OPTION value=\""+this[i]+"\">"+this[i]+"</OPTION>"
}
Z+="</SELECT>"
document.write(Z);
}
function MAJListe(txt,f)
{
if (txt!=this.search)
{
this.search=txt
f.elements[this.nom].options.length=0;
for (var i=0; i<this.nb; i++)
{
if ( this[i].substring(0,txt.length).toUpperCase()==txt.toUpperCase() )
{
var o=new Option(this[i], this[i]);
f.elements[this.nom].options[f.elements[this.nom].options.length]=o;
}
}
if (f.elements[this.nom].options.length==1)
{
f.elements[this.nom].selectedIndex=0;
}
}
}
function ListeCheck()
{
Liste.MAJ(document.forms["saisie"].search.value,document.forms["saisie"])
if (document.layers)
{
setTimeout("ListeCheck()", 1001)
}
else
{
setTimeout("ListeCheck()", 100)
}
}
</SCRIPT>
Partager