回答編集履歴
1
追記
test
CHANGED
@@ -157,3 +157,179 @@
|
|
157
157
|
</div>
|
158
158
|
|
159
159
|
```
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
# クリアと該当なし
|
164
|
+
|
165
|
+
クリアと該当なしを付けるの忘れてました
|
166
|
+
|
167
|
+
```javascript
|
168
|
+
|
169
|
+
$(function(){
|
170
|
+
|
171
|
+
$('#1-select,.checkbox-input,#3-select').on('change',function(){
|
172
|
+
|
173
|
+
var area=$('#1-select').val();
|
174
|
+
|
175
|
+
var city=[];
|
176
|
+
|
177
|
+
$('.checkbox-input:checked').each(function(){city.push($(this).val())});
|
178
|
+
|
179
|
+
var brand=$('#3-select').val();
|
180
|
+
|
181
|
+
$('#err').remove();
|
182
|
+
|
183
|
+
if(area=="" && city.length==0 && brand==""){
|
184
|
+
|
185
|
+
$('#store-data table tr').show();
|
186
|
+
|
187
|
+
}else{
|
188
|
+
|
189
|
+
var tr=$('#store-data table tr').hide().filter(function(){
|
190
|
+
|
191
|
+
return area==""?true:$(this).has("."+area).length>0;
|
192
|
+
|
193
|
+
}).filter(function(){
|
194
|
+
|
195
|
+
return brand==""?true:$(this).has("."+brand).length>0;
|
196
|
+
|
197
|
+
}).filter(function(){
|
198
|
+
|
199
|
+
return city.length==0?true:$(this).has("."+city.join(",.")).length>0;
|
200
|
+
|
201
|
+
}).show();
|
202
|
+
|
203
|
+
if(tr.length==0){
|
204
|
+
|
205
|
+
$("#store-data table").after($('<div>').attr('id','err').text("該当なし"));
|
206
|
+
|
207
|
+
}
|
208
|
+
|
209
|
+
}
|
210
|
+
|
211
|
+
}).eq(0).trigger('change');
|
212
|
+
|
213
|
+
$('#reset').on('click',function(e){
|
214
|
+
|
215
|
+
$('#1-select').prop('selectedIndex',0);
|
216
|
+
|
217
|
+
$('.checkbox-input').prop('checked',false);
|
218
|
+
|
219
|
+
$('#3-select').prop('selectedIndex',0).trigger('change');
|
220
|
+
|
221
|
+
});
|
222
|
+
|
223
|
+
});
|
224
|
+
|
225
|
+
```
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
```HTML
|
230
|
+
|
231
|
+
<div id="search-bx">
|
232
|
+
|
233
|
+
<select id="1-select" class="store-select" name="area">
|
234
|
+
|
235
|
+
<option value="">地域から検索</option>
|
236
|
+
|
237
|
+
<option value="1-area">1-地域</option>
|
238
|
+
|
239
|
+
<option value="2-area">2-地域</option>
|
240
|
+
|
241
|
+
<option value="3-area">3-地域</option>
|
242
|
+
|
243
|
+
</select>
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
<div id="2-checkbox">
|
248
|
+
|
249
|
+
<label><input type="checkbox" class="checkbox-input" name="city" value="1-city">1-都市</label>
|
250
|
+
|
251
|
+
<label><input type="checkbox" class="checkbox-input" name="city" value="2-city">2-都市</label>
|
252
|
+
|
253
|
+
<label><input type="checkbox" class="checkbox-input" name="city" value="3-city">3-都市</label>
|
254
|
+
|
255
|
+
</div>
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
<select id="3-select" class="store-select" name="brand">
|
260
|
+
|
261
|
+
<option value="">ブランド検索</option>
|
262
|
+
|
263
|
+
<option value="1-brand">1-ブランド</option>
|
264
|
+
|
265
|
+
<option value="2-brand">2-ブランド</option>
|
266
|
+
|
267
|
+
<option value="3-brand">3-ブランド</option>
|
268
|
+
|
269
|
+
</select>
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
<input type="button" id="reset" value="選択をクリアする">
|
274
|
+
|
275
|
+
</div>
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
<div id="store-data">
|
280
|
+
|
281
|
+
<table>
|
282
|
+
|
283
|
+
<thead>
|
284
|
+
|
285
|
+
<tr class="active">
|
286
|
+
|
287
|
+
<td>地域</td>
|
288
|
+
|
289
|
+
<td>都市</td>
|
290
|
+
|
291
|
+
<td>ブランド</td>
|
292
|
+
|
293
|
+
</tr>
|
294
|
+
|
295
|
+
</thead>
|
296
|
+
|
297
|
+
<tbody>
|
298
|
+
|
299
|
+
<tr>
|
300
|
+
|
301
|
+
<td class="area"><span class="1-area">1-地域</span></td>
|
302
|
+
|
303
|
+
<td class="city"><span class="1-city">1-都市</span></td>
|
304
|
+
|
305
|
+
<td class="brand"><span class="1-brand">1-ブランド</span></td>
|
306
|
+
|
307
|
+
</tr>
|
308
|
+
|
309
|
+
<tr>
|
310
|
+
|
311
|
+
<td class="area"><span class="1-area">1-地域</span></td>
|
312
|
+
|
313
|
+
<td class="city"><span class="2-city">2-都市</span></td>
|
314
|
+
|
315
|
+
<td class="brand"><span class="2-brand">2-ブランド</span></td>
|
316
|
+
|
317
|
+
</tr>
|
318
|
+
|
319
|
+
<tr>
|
320
|
+
|
321
|
+
<td class="area"><span class="1-area">1-地域</span></td>
|
322
|
+
|
323
|
+
<td class="city"><span class="3-city">3-都市</span></td>
|
324
|
+
|
325
|
+
<td class="brand"><span class="3-brand">3-ブランド</span></td>
|
326
|
+
|
327
|
+
</tr>
|
328
|
+
|
329
|
+
</tbody>
|
330
|
+
|
331
|
+
</table>
|
332
|
+
|
333
|
+
</div>
|
334
|
+
|
335
|
+
```
|