Bonsoir,
J'ai encore un petit problème :S
First Post : http://www.developpez.net/forums/d10...t/#post5688470
J'ai modifier mon tableau de données comme ceci :
Dans mon tableau 'quantity', j'ai imbriquer un tableau 'delais' qui me permet d'avoir le prix exact en fonction de la quantité et du délais choisi.
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
193
194
195
196
197
198
199
200 //////////////////////// FLYER ////////////////////////// arrayProductOptions= [ { //////////////////////// GRAMMAGE 135g ////////////////////////// "value":"135gr", "text":"135gr", "format": [ { //////////////////////// GRAMMAGE 135g / FORMAT A6 ////////////////////////// "value":"DIN A/6", "text":"DIN A/6", "image":"<image src='img_exemple/exemple_a6.jpg'/>", "impression": [ { //////////////////////// GRAMMAGE 135g / FORMAT A6 / RECTO&VERSO ////////////////////////// "value":"Recto/Verso", "text":"Recto/Verso", "quantity": [ { "number":"1000", "delais": [ { "jour":"8", "price":"35,00", }, { "jour":"5", "price":"50,00", }, { "jour":"2", "price":"105,00", } ] }, { "number":"2500", "delais": [ { "jour":"8", "price":"40,00", }, { "jour":"5", "price":"55,00", }, { "jour":"2", "price":"109,00", } ] }, { "number":"5000", "delais": [ { "jour":"8", "price":"52,00", }, { "jour":"5", "price":"72,00", }, { "jour":"2", "price":"144,00", } ] }, { "number":"7500", "delais": [ { "jour":"8", "price":"58,00", }, { "jour":"5", "price":"81,00", }, { "jour":"2", "price":"125,00", } ] }, { "number":"10000", "delais": [ { "jour":"8", "price":"85,00", }, { "jour":"5", "price":"115,00", }, { "jour":"2", "price":"135,00", } ] } ] }, { //////////////////////// GRAMMAGE 135g / FORMAT A6 / RECTO//////////////////////// "value":"Recto", "text":"Recto", "quantity": [ { "number":"1000", "delais": [ { "jour":"8", "price":"85,00", }, { "jour":"5", "price":"115,00", }, { "jour":"2", "price":"135,00", } ] }, { "number":"2500", "delais": [ { "jour":"8", "price":"85,00", }, { "jour":"5", "price":"115,00", }, { "jour":"2", "price":"135,00", } ] }, { "number":"5000", "delais": [ { "jour":"8", "price":"85,00", }, { "jour":"5", "price":"115,00", }, { "jour":"2", "price":"135,00", } ] }, { "number":"10000", "delais": [ { "jour":"8", "price":"85,00", }, { "jour":"5", "price":"115,00", }, { "jour":"2", "price":"135,00", } ] } ] } ] }, {
J'ai rajouter un champ dans mon formulaire (delaisID) ainsi qu'une fonction delaisChanged() qui est appeler quand on modifie la quantité, j'arrive a afficher mes données dans délais, mais mon prix ne se met pas plus a jour correctement a jour quand je modifie la quantité ou le délais
Merci d'avance
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 // TO DEFINE NEW PRODUCTS: arrayProducts= [ { "label":"Flyer", "page":"flyer.php" }, { "label":"Affiches", "page":"affiches.php" }, { "label":"Depliants", "page":"depliants.php" } ]; // DO NOT EDIT BELOW function productChanged() { var tt=document.getElementById("productID"); location.href=tt.options[tt.selectedIndex].value; } function composanteChanged() { var tt=document.getElementById("formatID"); // save selection var idxFormat=tt.selectedIndex; // re-init formats var data=arrayProductOptions[document.getElementById("composanteID").selectedIndex]["format"]; var i,n=data.length; if ((idxFormat>=n)||(idxFormat<0)) idxFormat=0; tt.options.length=n; for(i=0;i<n;i++) { tt.options[i]=new Option(data[i]["text"],data[i]["value"]); } tt.selectedIndex=idxFormat; formatChanged(); } function formatChanged() { // re-init impression var tt=document.getElementById("impressionID"); // save selection var idxImpression=tt.selectedIndex; // re-init impression var data=arrayProductOptions[document.getElementById("composanteID").selectedIndex]["format"][document.getElementById("formatID").selectedIndex]; document.getElementById("imageFormat").innerHTML=data["image"]; data=data["impression"]; var i,n=data.length; if ((idxImpression>=n)||(idxImpression<0)) idxImpression=0; tt.options.length=n; for(i=0;i<n;i++) { tt.options[i]=new Option(data[i]["text"],data[i]["value"]); } tt.selectedIndex=idxImpression; impressionChanged(); } function impressionChanged() { // re-init quantities var tt=document.getElementById("quantityID"); // save selection var idxQuantities=tt.selectedIndex; // re-init quantities var data=arrayProductOptions[document.getElementById("composanteID").selectedIndex]["format"] [document.getElementById("formatID").selectedIndex]["impression"] [document.getElementById("impressionID").selectedIndex]["quantity"]; var i,n=data.length; if ((idxQuantities>=n)||(idxQuantities<0)) idxQuantities=0; tt.options.length=n; for(i=0;i<n;i++) { tt.options[i]=new Option(data[i]["number"],data[i]["number"]); } tt.selectedIndex=idxQuantities; quantityChanged(); } function quantityChanged() { // Recuperation du tableau de donnees initiales var data=arrayProductOptions[document.getElementById("composanteID").selectedIndex]["format"] [document.getElementById("formatID").selectedIndex]["impression"] [document.getElementById("impressionID").selectedIndex]["quantity"]; // update price var tt=document.getElementById("outputPrice"); var ttq=document.getElementById("quantityID"); tt.value= data[ttq.selectedIndex]["price"]; delaisChanged(); } function delaisChanged() { // re-init quantities var tt=document.getElementById("delaisID"); // save selection var idxQuantities=tt.selectedIndex; // re-init quantities var data=arrayProductOptions[document.getElementById("quantityID").selectedIndex]["format"] [document.getElementById("formatID").selectedIndex]["impression"] [document.getElementById("impressionID").selectedIndex]["quantity"] [document.getElementById("quantityID").selectedIndex]["delais"]; var i,n=data.length; if ((idxQuantities>=n)||(idxQuantities<0)) idxQuantities=0; tt.options.length=n; for(i=0;i<n;i++) { tt.options[i]=new Option(data[i]["jour"],data[i]["jour"]); } tt.selectedIndex=idxQuantities; // update price var tt=document.getElementById("outputPrice"); var ttq=document.getElementById("quantityID"); tt.value= data[ttq.selectedIndex]["price"]; } function pageInit(idxProduct) { // init products var tt=document.getElementById("productID"); var i,n=arrayProducts.length; tt.options.length=n; for(i=0;i<n;i++) { tt.options[i]=new Option(arrayProducts[i]["label"],arrayProducts[i]["page"]); } tt.selectedIndex=idxProduct; // init composantes var tt=document.getElementById("composanteID"); tt.options.length=0 var i,n=arrayProductOptions.length; for(i=0;i<n;i++) { tt.options[i]=new Option(arrayProductOptions[i]["text"],arrayProductOptions[i]["value"]); } tt.selectedIndex=0; composanteChanged(); // add listeners document.getElementById("productID").onchange=productChanged; document.getElementById("composanteID").onchange=composanteChanged; document.getElementById("formatID").onchange=formatChanged; document.getElementById("impressionID").onchange=impressionChanged; document.getElementById("quantityID").onchange=quantityChanged; }
Partager