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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
<?php import_request_variables('pG', 'p_'); if($p_list_1!="") { $list_1=trim($p_list_1); } if($p_list_2!="") { $list_2=trim($p_list_2); } if($p_lv1!="") { $lv1=trim($p_lv1); } if($p_lv2!="") { $lv2=trim($p_lv2); } $navig['product_search']="ค้นหาผลิตภัณฑ์"; navigator($navig); bar_header("ค้นหาผลิตภัณฑ์"); // Bar_Header
if($p_startrow!="") { $startrow=trim($p_startrow); }
echo "<form name='search_form' method='post' action='index.php?mod=product_search&path=product'>"; echo "<table align='center' width='60%'>"; echo "<tr>"; echo "<td>"; echo print_arr1(); echo "<b>โดยหมวดหลัก</b>"; echo "</td>"; echo "<td>"; echo "<div id='lv1'><select>\n"; echo "<option value=''>==============</option> \n" ; echo "</select></div>\n"; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td>"; echo print_arr1(); echo "<b>โดยหมวดรอง</b>"; echo "</td>"; echo "<td>"; echo "<div id='lv2'><select>\n"; echo "<option value=''>==============</option> \n" ; echo "</select></div>\n"; echo "</td>"; echo "</tr>"; echo "</table>";
echo "<center><input type='submit' name='submit' value='ค้นหา'></center>"; echo "</form>";
if($_POST[submit]) { echo "<table>"; if($lv1!="" and $lv2=="") { $res = select_result_query("*" , "cms_product", "id_product" , "$lv1" ," order by name asc , has_child DESC"); display_result($lv1); } else if($lv1!="" and $lv2!="") { display_result($lv2); } echo "</table>"; }
?>
<script language="javascript" > function Inint_AJAX() { var xmlHttpRequest = false; // Proberen een nieuw object aan te maken. try { // Nakijken of de browser Microsoft Internet Explorer is if(window.ActiveXObject) { // Omdat elke versie van Internet Explorer een andere versie kan nodig hebben, // overlopen we elke mogelijke versie; van hoog naar laag. for(var i = 5; i; i--) { try { // De laatste versie kan niet geladen worden, dus moeten we teruggrijpen // naar een oudere variant. if(i == 2) { xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP"); // De laatste mogelijke versie laden } else { xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP." + i + ".0"); } break; } // Indien het object niet gemaakt kan worden, moeten we dit helaas zo teruggeven. catch(excNotLoadable) { xmlHttpRequest = false; } } } // Browsers als Opera, Mozilla (Firefox) en Safari kunnen de 'gewone' manier gebruiken else if(window.XMLHttpRequest) { xmlHttpRequest = new XMLHttpRequest(); } } // Het is mogelijk dat de browser het object aanmaken niet ondersteunt; ook in dit geval sturen we // dan ook geen object terug. catch(excNotLoadable) { xmlHttpRequest = false; } // Het gemaakte object (of 'false' in het geval dat er een probleem was) teruggeven return xmlHttpRequest;
} function dochange(src, val, val2) { // document.getElementById("list_1").value=val; // document.getElementById("list_2").value=val2; var req = Inint_AJAX(); // xmlHttpRequest.overrideMimeType('text/xml'); //req.overrideMimeType('text/xml'); req.onreadystatechange = function() { if (req.readyState==4) { if (req.status==200) { document.getElementById(src).innerHTML=req.responseText; //retuen value } } }; req.open("GET","coremain/module/product/product_ajax_content.php?data="+src+"&val="+val+"&val2="+val2); //make connection req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8"); // set Header req.send(null); //send value } </script>
<?php echo "<script language='Javascript'>";
if($lv1!="" and $lv2=="") { echo "window.onLoad=dochange('lv1','$lv1', '');"; echo "window.onLoad=dochange('lv2','$lv1', '');"; } else if($lv1!="" and $lv2!="" ) { echo "window.onLoad=dochange('lv1','$lv1', '');"; echo "window.onLoad=dochange('lv2','$lv1','$lv2');"; } else { echo "window.onLoad=dochange('lv1','', '');"; } echo "</script>"; ?>
<?php function display_result($id_product){
//echo "<br/>".$id_product."<br/>"; //if ($show_count<=$show_limit ) //{ $res_show = select_result_query("*" , "cms_product", "id_product" , "$id_product" ,"order by name asc , has_child DESC"); while ($data_show = mysql_fetch_array ($res_show)) { //if($show_count<=$show_limit) //{ if($data_show[id_parent]!=0) { echo "<tr>"; echo "<td align='center' width='40%'>"; picture_frame($_SESSION[web_name]."/module_product/picture/$data_show[picture]","index.php?mod=product_sub_detail&path=product&id_product=$data_show[id_product]"); echo "</td>"; echo "<td align='left' width='60%'>"; echo "<table width='100%'>"; echo "<tr>"; echo "<td>"; echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>"; echo "<tr bgcolor='gray'>"; echo "<td>"; echo "หมวด"; print_group($data_show[id_product]); echo "</td>"; echo "</tr>"; echo "</table>"; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td>"; echo "ชื่อผลิตภัณฑ์ : ".$data_show[name]; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td>"; echo "รายละเอียด : ".$data_show[description]; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td>"; if($data_show[attach_file]!="") echo "ไฟล์แนบ : <a href='".$_SESSION[web_name]."/module_product/attach/$data_show[attach_file]'>$data_show[old_attach_name]</a>"; echo "</td>"; echo "</tr>"; echo "</table>"; echo "</td>"; echo "</tr>"; // $show_limit++; } else { $data_child = select_result_query("*","cms_product","id_parent",$data_show[id_product] ," order by name asc , has_child DESC"); while ($data_sub = mysql_fetch_array($data_child)) { display_result($data_sub[id_product]); } } //} else //return false; } //} return true;; } function print_group($id_product) { $result_parent = select_result_query("*" , "cms_product", "id_product" , "$id_product"); while ($data_parent = mysql_fetch_array($result_parent)) { if($data_parent[id_parent]!=0) { print_group($data_parent[id_parent]); } if($data_parent[has_child]==1) { // echo "<td>"; echo print_arr1(); echo " "; // echo "</td>"; // echo "<td>"; echo $data_parent[name]; echo " "; // echo "</td>"; } } } ?>
|