Bonjour à tous et à toutes,
Je souhaiterez afficher un select chargé en ajax que si sa valeur est différente de NULL mais j'ai beau essayer je n'arrive pas vraiment au résultat voulu.
Dans l'idéale il vaudrait que le select s'affiche que si sa valeur est différente de NULL, aussi non j'affiche le bouton de validation.
Pour une sélection de produit j'ai cinq finitions possible.
J'ai donc cinq select en tous mais les deux dernier peuvent être NULL car tous mes produits non pas cinq finitions possible, parfois il peut y en avoir que trois ou quatre.

Dans ma bdd les champs des produits ou il n'y a pas de quatrième et/ou de cinquième finition sont rempli NULL.
Dans le css l'affichage est à none.
Ca fonctionne presque mais il me manque un petit je ne sais quoi pour que tous fonctionne correctement.

Voici mon script qui charge et affiche les select

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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
 
function requestfinition_1() 
	{
		var listfinition_1 = document.getElementById('finition_1Select');
		var valuefinition_1 = listfinition_1.options[listfinition_1.selectedIndex].value;
		var xhr   = getXMLHttpRequest();
		xhr.onreadystatechange = function()
			{
				if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0))
					{
						readData(xhr.responseXML);
						document.getElementById("chargement").style.display = "none";
					}
				else if (xhr.readyState < 4)
					{
						document.getElementById("chargement").style.display = "inline";
					}
			};
		xhr.open("POST","../insert/ajax_finition_1.php",true);
		xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xhr.send("Idfinition_1=" + valuefinition_1);
	}
function requestfinition_2()
	{
		var listfinition_1 = document.getElementById('finition_1Select');
		var valuefinition_1 = listfinition_1.options[listfinition_1.selectedIndex].value;
		var listfinition_2 = document.getElementById('finition_2Select');
		var valuefinition_2 = listfinition_2.options[listfinition_2.selectedIndex].value;
		var xhr   = getXMLHttpRequest();
		xhr.onreadystatechange = function()
			{
				if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0))
					{
						readDatafinition_2(xhr.responseXML);
						document.getElementById("chargement").style.display = "none";
					}
				else if (xhr.readyState < 4)
					{
						document.getElementById("chargement").style.display = "inline";
					}
			};
		xhr.open("POST","../insert/ajax_finition_2.php",true);
		xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xhr.send("Idfinition_1="+valuefinition_1+"&Idfinition_2="+valuefinition_2);
	}
function requestfinition_3()
	{
		var listfinition_1 = document.getElementById('finition_1Select');
		var valuefinition_1 = listfinition_1.options[listfinition_1.selectedIndex].value;
		var listfinition_2 = document.getElementById('finition_2Select');
		var valuefinition_2 = listfinition_2.options[listfinition_2.selectedIndex].value;
		var listfinition_3 = document.getElementById('finition_3Select');
		var valuefinition_3 = listfinition_3.options[listfinition_3.selectedIndex].value;
		var xhr   = getXMLHttpRequest();
		xhr.onreadystatechange = function()
			{
				if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0))
					{
						readDatafinition_3(xhr.responseXML);
						document.getElementById("chargement").style.display = "none";
					}
				else if (xhr.readyState < 4)
					{
						document.getElementById("chargement").style.display = "inline";
					}
			};
		xhr.open("POST","../insert/ajax_finition_3.php",true);
		xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xhr.send("Idfinition_1="+valuefinition_1+"&Idfinition_2="+valuefinition_2+"&Idfinition_3="+valuefinition_3);
		if (valuefinition_3 != "NULL")
			{
				document.getElementById("Select4").style.display = "inline";
				document.getElementById("Select5").style.display = "none";
				document.getElementById("slection_choisi").style.display = "none";
			}
		else
			{
				document.getElementById("Select4").style.display = "none";
				document.getElementById("Select5").style.display = "none";
				document.getElementById("slection_choisi").style.display = "inline";
			}
	}
function requestfinition_4()
	{
		var listfinition_1 = document.getElementById('finition_1Select');
		var valuefinition_1 = listfinition_1.options[listfinition_1.selectedIndex].value;
		var listfinition_2 = document.getElementById('finition_2Select');
		var valuefinition_2 = listfinition_2.options[listfinition_2.selectedIndex].value;
		var listfinition_3 = document.getElementById('finition_3Select');
		var valuefinition_3 = listfinition_3.options[listfinition_3.selectedIndex].value;
		var listfinition_4 = document.getElementById('finition_4Select');
		var valuefinition_4 = listfinition_4.options[listfinition_4.selectedIndex].value;
		var xhr   = getXMLHttpRequest();
		xhr.onreadystatechange = function()
			{
				if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0))
					{
						readDatafinition_4(xhr.responseXML);
						document.getElementById("chargement").style.display = "none";
					}
				else if (xhr.readyState < 4)
					{
						document.getElementById("chargement").style.display = "inline";
					}
			};
		xhr.open("POST","../insert/ajax_finition_4.php",true);
		xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xhr.send("Idfinition_1="+valuefinition_1+"&Idfinition_2="+valuefinition_2+"&Idfinition_3="+valuefinition_3+"&Idfinition_4="+valuefinition_4);
		if (valuefinition_4 != "NULL")
			{
				document.getElementById("Select4").style.display = "inline";
				document.getElementById("Select5").style.display = "none";
				document.getElementById("slection_choisi").style.display = "none";
			}
		else
			{
				document.getElementById("Select4").style.display = "none";
				document.getElementById("Select5").style.display = "none";
				document.getElementById("slection_choisi").style.display = "inline";
			}
	}
function readData(oData)
	{
		var nodes   = oData.getElementsByTagName("item");
		var oSelect = document.getElementById("finition_2Select");
		var oOption, oInner;
		oSelect.innerHTML = "";
		for (var i=0, c=nodes.length; i<c; i++)
			{
				oOption = document.createElement("option");
				oInner  = document.createTextNode(nodes[i].getAttribute("name"));
				oOption.value = nodes[i].getAttribute("id");
				oOption.appendChild(oInner);
				oSelect.appendChild(oOption);
			}
	}
function readDatafinition_2(oDatafinition_2)
	{
		var nodesfinition_2 = oDatafinition_2.getElementsByTagName("item");
		var oSelectfinition_2 = document.getElementById("finition_3Select");
		var oOptionfinition_2, oInnerfinition_2;
		oSelectfinition_2.innerHTML = "";
		for (var i=0, c=nodesfinition_2.length; i<c; i++)
			{
				oOptionfinition_2 = document.createElement("option");
				oInnerfinition_2  = document.createTextNode(nodesfinition_2[i].getAttribute("name"));
				oOptionfinition_2.value = nodesfinition_2[i].getAttribute("id");
				oOptionfinition_2.appendChild(oInnerfinition_2);
				oSelectfinition_2.appendChild(oOptionfinition_2);
			}
	}
function readDatafinition_3(oDatafinition_3)
	{
		var nodesfinition_3 = oDatafinition_3.getElementsByTagName("item");
		var oSelectfinition_3 = document.getElementById("finition_4Select");
		var oOptionfinition_3, oInnerfinition_3;
		oSelectfinition_3.innerHTML = "";
		for (var i=0, c=nodesfinition_3.length; i<c; i++)
			{
				oOptionfinition_3 = document.createElement("option");
				oInnerfinition_3  = document.createTextNode(nodesfinition_3[i].getAttribute("name"));
				oOptionfinition_3.value = nodesfinition_3[i].getAttribute("id");
				oOptionfinition_3.appendChild(oInnerfinition_3);
				oSelectfinition_3.appendChild(oOptionfinition_3);
			}
	}
function readDatafinition_4(oDatafinition_4)
	{
		var nodesfinition_4 = oDatafinition_4.getElementsByTagName("item");
		var oSelectfinition_4 = document.getElementById("finition_5Select");
		var oOptionfinition_4, oInnerfinition_4;
		oSelectfinition_4.innerHTML = "";
		for (var i=0, c=nodesfinition_4.length; i<c; i++)
			{
				oOptionfinition_4 = document.createElement("option");
				oInnerfinition_4  = document.createTextNode(nodesfinition_4[i].getAttribute("name"));
				oOptionfinition_4.value = nodesfinition_4[i].getAttribute("id");
				oOptionfinition_4.appendChild(oInnerfinition_4);
				oSelectfinition_4.appendChild(oOptionfinition_4);
			}
	}
function selection_ok(valeur)
	{
		if (valeur=='none')
			{
				document.getElementById("slection_choisi").style.display = "none";
			}
		else
			{
				document.getElementById("slection_choisi").style.display = "inline";
			}
	}
requestfinition_1 et requestfinition_2 ne sont jamais NULL mais requestfinition_3 et requestfinition_4 peuvent l'être.
Merci de votre aide.