質問編集履歴
1
最初に書いた内容かが何故か反映されてなかった為、修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -170,11 +170,41 @@
|
|
170
170
|
|
171
171
|
$('#select-pref').append(buf);
|
172
172
|
|
173
|
+
}
|
174
|
+
|
175
|
+
});
|
176
|
+
|
177
|
+
});
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
// 2つ目の選択
|
182
|
+
|
173
|
-
|
183
|
+
$('#select-pref').on('change', function () {
|
184
|
+
|
174
|
-
|
185
|
+
//1つ目が選ばれたら〜
|
186
|
+
|
187
|
+
$('#select-city option:nth-child(n+2)').remove(); // select-cityの2つ目のoptionをクリア
|
188
|
+
|
189
|
+
$('#select-town option:nth-child(n+2)').remove(); // select-townの2つ目のoptionをクリア
|
190
|
+
|
191
|
+
|
192
|
+
|
175
|
-
|
193
|
+
let select_prefid = $('#select-pref option:selected').val();
|
176
|
-
|
194
|
+
|
195
|
+
|
196
|
+
|
177
|
-
|
197
|
+
$.getJSON('/head/grade/json/lesson2.json', function (data) {
|
198
|
+
|
199
|
+
let pref = data.find((p) => p.prefid === select_prefid);
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
for ( let city of pref.city ){
|
204
|
+
|
205
|
+
let buf = '<option value="' + city.cityid + '">' + city.cityname + '</option>';
|
206
|
+
|
207
|
+
$('#select-city').append(buf);
|
178
208
|
|
179
209
|
console.log(buf);
|
180
210
|
|
@@ -186,41 +216,27 @@
|
|
186
216
|
|
187
217
|
|
188
218
|
|
189
|
-
//
|
219
|
+
// 3つ目の選択
|
190
|
-
|
220
|
+
|
191
|
-
$('#select-
|
221
|
+
$('#select-city').on('change', function () {
|
192
|
-
|
193
|
-
|
222
|
+
|
194
|
-
|
195
|
-
$('#select-city option:nth-child(n+2)').remove(); // select-cityの2つ目のoptionをクリア
|
196
|
-
|
197
|
-
$('#select-town option:nth-child(n+2)').remove(); // select-townの2つ目のoptionをクリア
|
223
|
+
$('#select-town option:nth-child(n+2)').remove(); // select-townの2つ目のoptionをクリア
|
198
|
-
|
199
|
-
|
200
|
-
|
224
|
+
|
201
|
-
|
225
|
+
var select_prefid = $('#select-pref option:selected').val();
|
226
|
+
|
202
|
-
|
227
|
+
var select_cityid = $('#select-city option:selected').val();
|
203
|
-
|
204
228
|
|
205
229
|
$.getJSON('/head/grade/json/lesson2.json', function (data) {
|
206
230
|
|
207
231
|
let pref = data.find((p) => p.prefid === select_prefid);
|
208
232
|
|
209
|
-
|
233
|
+
let city = pref.city.find((c) => c.cityid === select_cityid);
|
210
|
-
|
211
|
-
|
234
|
+
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
//★for文
|
216
|
-
|
217
|
-
for ( let
|
235
|
+
for ( let town of city.town ){
|
218
|
-
|
236
|
+
|
219
|
-
let buf = '<option value="' +
|
237
|
+
let buf = '<option value="' + town.townid + '">' + town.townname + '</option>';
|
220
|
-
|
221
|
-
|
238
|
+
|
222
|
-
|
223
|
-
$('#select-
|
239
|
+
$('#select-town').append(buf);
|
224
240
|
|
225
241
|
console.log(buf);
|
226
242
|
|
@@ -230,38 +246,6 @@
|
|
230
246
|
|
231
247
|
});
|
232
248
|
|
233
|
-
|
234
|
-
|
235
|
-
// 3つ目の選択
|
236
|
-
|
237
|
-
$('#select-city').on('change', function () {
|
238
|
-
|
239
|
-
$('#select-town option:nth-child(n+2)').remove(); // select-townの2つ目のoptionをクリア
|
240
|
-
|
241
|
-
var select_prefid = $('#select-pref option:selected').val();
|
242
|
-
|
243
|
-
var select_cityid = $('#select-city option:selected').val();
|
244
|
-
|
245
|
-
$.getJSON('/head/grade/json/lesson2.json', function (data) {
|
246
|
-
|
247
|
-
let pref = data.find((p) => p.prefid === select_prefid);
|
248
|
-
|
249
|
-
let city = pref.city.find((c) => c.cityid === select_cityid);
|
250
|
-
|
251
|
-
for ( let town of city.town ){
|
252
|
-
|
253
|
-
let buf = '<option value="' + town.townid + '">' + town.townname + '</option>';
|
254
|
-
|
255
|
-
$('#select-town').append(buf);
|
256
|
-
|
257
|
-
console.log(buf);
|
258
|
-
|
259
|
-
}
|
260
|
-
|
261
|
-
});
|
262
|
-
|
263
|
-
});
|
264
|
-
|
265
249
|
</script>
|
266
250
|
|
267
251
|
```
|
@@ -270,14 +254,12 @@
|
|
270
254
|
|
271
255
|
### 試したこと
|
272
256
|
|
273
|
-
|
257
|
+
$('.js_search').on('click',function(){
|
258
|
+
|
259
|
+
|
260
|
+
|
274
|
-
|
261
|
+
});
|
262
|
+
|
275
|
-
こ
|
263
|
+
発火させるキーはこれだと思います。
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
264
|
+
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
265
|
+
根本的な書き方がわからず、申し訳ございません。
|