par
bercy » 01 oct. 2006, 20:13
Voici le code complet du javascript
Code : Tout sélectionner
<SCRIPT LANGUAGE="JavaScript">
// D'autres scripts et des tutoriaux sur http://www.toutjavascript.com
// Script développé par Tout JavaScript.com
// Si vous utilisez ce script, merci de laisser ce commentaire
var Liste=new CreerListe("Pays", 5, 200)
Liste.Add("Afghanistan");
Liste.Add("Afrique du sud");
Liste.Add("Albanie");
Liste.Add("Algérie");
Liste.Add("Allemagne");
Liste.Add("Andorre");
Liste.Add("Angola");
Liste.Add("Antigua-et-Barbuda");
Liste.Add("Arabie");
Liste.Add("Argentine");
Liste.Add("Arménie");
Liste.Add("Australie");
Liste.Add("Autriche");
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++;
}
function AfficherListe() {
if (document.layers) {
var Z="<SELECT name="+this.nom+" size="+this.hauteur+">";
} else {
var Z="<SELECT name="+this.nom+" size="+this.hauteur+" 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["monform"].search.value,document.forms["monform"])
if (document.layers) {
setTimeout("ListeCheck()", 1001)
} else {
setTimeout("ListeCheck()", 100)
}
}
</SCRIPT>
==================================================
==================================================
<FORM name=monform>
<INPUT type=text name=search><BR>
<SCRIPT language=javascript>
Liste.Afficher();
ListeCheck();
</SCRIPT>
</FORM>
Merci d'avance
Voici le code complet du javascript
[code]
<SCRIPT LANGUAGE="JavaScript">
// D'autres scripts et des tutoriaux sur http://www.toutjavascript.com
// Script développé par Tout JavaScript.com
// Si vous utilisez ce script, merci de laisser ce commentaire
var Liste=new CreerListe("Pays", 5, 200)
Liste.Add("Afghanistan");
Liste.Add("Afrique du sud");
Liste.Add("Albanie");
Liste.Add("Algérie");
Liste.Add("Allemagne");
Liste.Add("Andorre");
Liste.Add("Angola");
Liste.Add("Antigua-et-Barbuda");
Liste.Add("Arabie");
Liste.Add("Argentine");
Liste.Add("Arménie");
Liste.Add("Australie");
Liste.Add("Autriche");
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++;
}
function AfficherListe() {
if (document.layers) {
var Z="<SELECT name="+this.nom+" size="+this.hauteur+">";
} else {
var Z="<SELECT name="+this.nom+" size="+this.hauteur+" 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["monform"].search.value,document.forms["monform"])
if (document.layers) {
setTimeout("ListeCheck()", 1001)
} else {
setTimeout("ListeCheck()", 100)
}
}
</SCRIPT>
==================================================
==================================================
<FORM name=monform>
<INPUT type=text name=search><BR>
<SCRIPT language=javascript>
Liste.Afficher();
ListeCheck();
</SCRIPT>
</FORM>[/code]
Merci d'avance