Erreur dans le code html?
Bonjour,
nouveau sur ce forum, j'espère y trouver une solution au non fonctionnement de mon code html.
Je voudrais créer une liste déroulante à 2 cases + liens.
J'ai essayé comme ça :
Code:
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
| 1.<html>
2.<title>liste déroulante dynamique</title>
3.<head>
4.<script language="Javascript" type="text/javascript" >
5.function choix(formulaire)
6.{
7.var j;
8.var i = formulaire.boite1.selectedIndex;
9.if (i == 0)
10.for(j = 1; j <3; j++)
11.formulaire.boite2.options[j].text="";
12.
13.
14.else
15.{
16.switch (i)
17.{
18.case 1 : var text = new Array( "un","deux","trois");
19.break;
20.
21.case 2 : var text = new Array("quatre","cinq","six");
22.break;
23.
24.case 3 : var text = new Array("sept","huit","neuf");
25.break;
26.}
27.
28.for(j = 0; j<3; j++)
29.formulaire.boite2.options[j+1].text=text[j];
30.}
31.formulaire.boite2.selectedIndex=0;
32.}
33.</script>
34.</head>
35.
36.<body>
37.<form name="formulaire">
38.<select name="boite1" onChange="choix(this.form)">
39.<OPTION>-- Choisissez une page ---</OPTION>
40.<option>livre</option>
41.<option>book</option>
42.<option>cahier</option>
43.
44.</select>
45.
46.<select name="boite2">
47.<OPTION>-- Choisissez une page ---</OPTION>
48.<option></option>
49.<option></option>
50.<option></option>
51.
52.</form>
53.</select>
54.</body>
55.</html> |
Mon problème c'est que je souhaiterais avoir dans la première case 3 choix possibles:
1) book
2) livre
3) cahier
et en fonction du choix dans la première case, dans la deuxième on verra :
si book => un, deux, trois
si livre => quatre, cinq, six
si cahier => sept, huit, neuf
MAIS un, deux, tois, quatre etc. doivent être des liens! Je ne sais plus comment faire, j'ai déjà essayé avec <a herf> et ça ne marche pas !
Quel code html utiliser et où le placer ?
Merci