
le 10/12/2004 à 19:21
bibi
bijour tout le monde
en fait j'avais pris une source sur toutjavascript qui est la suivante:
ca marche et j'ai donc essayé de l'adapter à ma saucer mais le select s'affiche pas:
jvous montre comment j'ai fait:
et donc voila la select box s'affiche plus donc si qqn peut m'aider ca srai cool merki davance
en fait j'avais pris une source sur toutjavascript qui est la suivante:
- <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("...");
- Liste.Add("Zimbabwe");
- 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>
- </HEAD>
- <BODY bgcolor="#FFFFFF" text="#FAFAFF" alink="#000066" link="#000066" vlink="#000066" >
- <FONT FACE="Arial" SIZE='-1' COLOR="navy">
- <BR><CENTER>
- <BIG><B>Liste déroulante avec recherche par clavier</B></BIG><BR><BR></CENTER>
- <BR>
- Ce script permet de réduire le contenu d'une liste en tapant le début du libellé.<BR>
- Tapez par exemple "a" dans la zone de texte. Tous les pays commençant par A sont affichés dans la liste.<BR>
- Tapez "al", les pays Albanie, Algérie et Allemagne restent dans la liste.<BR>
- Tapez "all", Allemagne reste seul dans la liste et se sélectionne.<BR>
- Si vous videz la zone de recherche, tous les pays ré-apparaissent.<BR>
- <BR>
- <FORM name=monform>
- <INPUT type=text name=search><BR>
- <SCRIPT language=javascript>
- Liste.Afficher();
- ListeCheck();
- </SCRIPT>
- </FORM>
ca marche et j'ai donc essayé de l'adapter à ma saucer mais le select s'affiche pas:
jvous montre comment j'ai fait:
- <script language=javascript>
- var Liste=new CreerListe("pseudo", 5, 200)
- 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.Fermer=FermerListe;
- this.MAJ=MAJListe;
- }
- function AjouterItem(item,num) {
- this[num]=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>"
- }
- */
- document.write(Z);
- }
- function FermerListe()
- {
- document.write("</select>");
- }
- 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>
- <?
- $pseudo= mysql_query('SELECT NomUser,NumUser FROM user ORDER BY NomUser ASC') or die (mysql_error());
- while($nom=mysql_fetch_array($pseudo))
- {
- ?><script type="text/javascript">Liste.Add(<?= $nom['NomUser']; ?>,<?= $nom['NumUser']; ?>);</script>
- <?
- }
- ?>
- <form name="search" method="post" />
- <input type="text" name="pseudo" size="15" maxlength="30" /><br/>
- <SCRIPT language=javascript>
- Liste.Afficher();
- Liste.Fermer();
- ListeCheck();
- </script></form>
et donc voila la select box s'affiche plus donc si qqn peut m'aider ca srai cool merki davance