Transformer 1 liste déroulante en 1 javascrip
Fermé
webmaster73
-
20 sept. 2002 à 15:12
Bobinours
Bobinours
- Messages postés
- 2898
- Date d'inscription
- jeudi 26 avril 2001
- Statut
- Membre
- Dernière intervention
- 21 mars 2013
A voir également:
- Transformer 1 liste déroulante en 1 javascrip
- Liste déroulante excel - Guide
- Liste déroulante en cascade ✓ - Forum - Astuces et Solutions
- Liste déroulante excel (saisie 1ères lettres) - Forum - Excel
- Excel liste déroulante conditionnelle ✓ - Forum - Excel
- Supprimer liste déroulante excel ✓ - Forum - Excel
3 réponses
Bobinours
21 sept. 2002 à 13:06
- Messages postés
- 2898
- Date d'inscription
- jeudi 26 avril 2001
- Statut
- Membre
- Dernière intervention
- 21 mars 2013
21 sept. 2002 à 13:06
Salut,
Fais comme ceci :
# FICHIER : externe.js
########################
document.write('<FORM name="menu1">');
document.write('<SELECT class="sel" name="service" ');
document.write('onchange="if (this.options[this.selectedIndex].value.length!=0) window.open(this.options[this.selectedIndex].value,\'centre\')">');
document.write('<OPTION selected value="">quelques sites</OPTION>');
document.write('<OPTION value="">------------------</OPTION>');
document.write('<OPTION value=" http://www.vega.fr.st">art</OPTION>');
document.write('<OPTION value=" http://www.augalop.fr.st">cheval</OPTION>');
document.write('<OPTION value="">-----------------</OPTION>');
document.write('</SELECT>');
document.write('<SCRIPT language="Javascript" type="text/javascript"><!-- document.menu1.service.selectedIndex=0;//--></SCRIPT>');
document.write('</FORM>');
# FICHIER : page.htm
########################
<SCRIPT language="Javascript" type="text/javascript" src="externe.js"></SCRIPT>
-= Bobinours =-
La Belette Contrée : http://bobin.underlands.org/cgi-bin/bel
Fais comme ceci :
# FICHIER : externe.js
########################
document.write('<FORM name="menu1">');
document.write('<SELECT class="sel" name="service" ');
document.write('onchange="if (this.options[this.selectedIndex].value.length!=0) window.open(this.options[this.selectedIndex].value,\'centre\')">');
document.write('<OPTION selected value="">quelques sites</OPTION>');
document.write('<OPTION value="">------------------</OPTION>');
document.write('<OPTION value=" http://www.vega.fr.st">art</OPTION>');
document.write('<OPTION value=" http://www.augalop.fr.st">cheval</OPTION>');
document.write('<OPTION value="">-----------------</OPTION>');
document.write('</SELECT>');
document.write('<SCRIPT language="Javascript" type="text/javascript"><!-- document.menu1.service.selectedIndex=0;//--></SCRIPT>');
document.write('</FORM>');
# FICHIER : page.htm
########################
<SCRIPT language="Javascript" type="text/javascript" src="externe.js"></SCRIPT>
-= Bobinours =-
La Belette Contrée : http://bobin.underlands.org/cgi-bin/bel
Bobinours
24 sept. 2002 à 01:53
- Messages postés
- 2898
- Date d'inscription
- jeudi 26 avril 2001
- Statut
- Membre
- Dernière intervention
- 21 mars 2013
24 sept. 2002 à 01:53
J'ai négligé un point. Il faut préférer un seul document.write() à plusieurs (économie de fonction avec Entrée/Sortie vers l'écran.
Pour cela, deux astuces :
1) Affecter une variable, puis l'afficher :
var texte = '<FORM name="menu1">';
texte += '<SELECT class="sel" name="service" ';
texte += 'onchange="if (this.options[this.selectedIndex].value.length!=0) window.open(this.options[this.selectedIndex].value,\'centre\')">';
...
2) Afficher avec des concaténations :
document.write(''
+ '<FORM name="menu1">'
+ '<SELECT class="sel" name="service" '
+ 'onchange="if (this.options[this.selectedIndex].value.length!=0) window.open(this.options[this.selectedIndex].value,\'centre\')">'
+'');
...
Enfin, tu peux aussi construire la liste de toute pièce en javaScript, dans l'esprit Programmation Orientée Objet, mais je n'ai pas d'exemple.
-= Bobinours =-
Une Contrée? http://bobin.underlands.org/cgi-bin/belette.pl
Pour cela, deux astuces :
1) Affecter une variable, puis l'afficher :
var texte = '<FORM name="menu1">';
texte += '<SELECT class="sel" name="service" ';
texte += 'onchange="if (this.options[this.selectedIndex].value.length!=0) window.open(this.options[this.selectedIndex].value,\'centre\')">';
...
2) Afficher avec des concaténations :
document.write(''
+ '<FORM name="menu1">'
+ '<SELECT class="sel" name="service" '
+ 'onchange="if (this.options[this.selectedIndex].value.length!=0) window.open(this.options[this.selectedIndex].value,\'centre\')">'
+'');
...
Enfin, tu peux aussi construire la liste de toute pièce en javaScript, dans l'esprit Programmation Orientée Objet, mais je n'ai pas d'exemple.
-= Bobinours =-
Une Contrée? http://bobin.underlands.org/cgi-bin/belette.pl