Bonjour,

je débute complet en javascipt mais dans le cadre de mon stage PHP/mySQL je dois en implémenter par ci par là.. Je viens de trouver un code sur la FAQ du site que j'ai tenté d'adapter à mon usage. Il sert à lier deux listes déroulantes entre elles.
Dans la première, mes valeurs s'affichent, par contre, la deuxième reste vide!
Je ne trouve pas mon erreur, pourriez-vous m'aider s'il vous plaît????

Voilà le script :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
56
57
58
59
60
61
62
63
64
65
66
 
<html>
<head>
	<script type="text/javascript" language="javascript">
		var table = new Array;
		table[0] = new Array("t0", "ARN");
		table[1] = new Array("t1", "CENTER");
		table[2] = new Array("t2", "CONTRIBUTORS");
 
		var champs=new Array; //ARN
		champs["t0"] = new Array;
		champs["t0"][0] = new Array("t0c0", "ARN-ID_ARN");
		champs["t0"][1] = new Array("t0c1", "ARN-RIN");
		champs["t0"][2] = new Array("t0c2", "ARN-ID_YIELD");
		champs["t0"][3] = new Array("t0c3", "ARN-ID_QUANTITY");
		champs["t0"][4] = new Array("t0c4", "ARN-ID_MITOSE");
		champs["t0"][5] = new Array("t0c5", "ARN-ID_MIT_NB");
 
		var champs=new Array; //CENTER
		champs["t1"] = new Array;
		champs["t1"][0] = new Array("t1c0", "CENTER-ID_CENTER");
		champs["t1"][1] = new Array("t1c1", "CENTER-NAME_CENTER");
 
		var champs=new Array; //CONTRIBUTORS
		champs["t2"] = new Array;
		champs["t2"][0] = new Array("t2c0", "CONTRIBUTORS-ID_CONTRIB");
		champs["t2"][1] = new Array("t2c1", "CONTRIBUTORS-NAME_CONTRIB");
 
	function filltheselect(liste, choix)
	{
	raz("listechamp");
		for (i=0; i<champ[choix].length; i++)
		{
			new_option = new Option(champ[choix][i][1],champ[choix][i][0]);
			document.formu.elements["listechamp"].options[document.formu.elements["listechamp"].length]=new_option;
		}
	}
 
	function raz(liste)
	{l=document.formu.elements[liste].length;
	for (i=l; i>=0; i--)
		document.formu.elements[liste].options[i]=null;
	}
 
	</script>
</head>
 
<body>
<form name="formu">
Choisir une table
<select name="listetable" onChange='filltheselect(this.name, this.value)'>
	<script language="javascript">
	for (i=0; i<table.length; i++)
		document.write("<option value=\"" +table[i][0]+ "\">" +table[i][1]);
	</script>
</select><br>
Choisir un champ
<select name="listechamp" onChange='filltheselect(this.name, this.value)'>
	<script language="javascript">
	for (i=0; i<champ["t0"].length; i++)
		document.write("<option value=\"" +champ["t0"][i][0]+ "\">" +champ["t0"][i][1]);
	</script>
</select><br>
</form>
</body>
</html>