質問するログイン新規登録

質問編集履歴

1

文法の修正

2021/07/12 03:48

投稿

aasifiuuf
aasifiuuf

スコア3

title CHANGED
File without changes
body CHANGED
@@ -18,32 +18,22 @@
18
18
  ```javascript,html
19
19
  ソースコード
20
20
  ```
21
- HTML
22
-
23
21
  <!DOCTYPE html>
24
22
  <html lang="ja">
25
23
  <head>
26
24
  <meta charset="UTF-8">
27
25
  </head>
28
26
  <body>
27
+
28
+
29
29
  <select name="genre" id="genre" onchange="createMenu(this.value)">
30
30
  <option disabled selected>ジャンルを選択してください</option>
31
31
  <option value="japaneseFoods">和食</option>
32
32
  <option value="chineseFoods">中華</option>
33
33
  <option value="italianFoods">イタリアン</option>
34
34
  </select>
35
- <select name="menuList" id="menuList" disabled>
35
+ <script type="text/javascript">
36
- <option disabled selected>料理を選択してください</option>
37
- </select>
38
- </body>
39
- </html>
40
-
41
-
42
-
43
- javascript
44
-
45
-
46
- const foodMenu =
36
+ const foodMenu =
47
37
  {
48
38
  "japaneseFoods": ["寿司", "天ぷら", "おでん"],
49
39
  "chineseFoods": ["八宝菜", "麻婆豆腐", "エビチリ"],
@@ -52,7 +42,7 @@
52
42
 
53
43
 
54
44
  function createMenu(selectGenre){
55
-
45
+
56
46
  let menuList = document.getElementById('menuList');
57
47
  menuList.disabled = false;
58
48
  menuList.innerHTML = '';
@@ -60,20 +50,25 @@
60
50
  option.innerHTML = '料理を選択してください';
61
51
  option.defaultSelected = true;
62
52
  option.disabled = true;
63
- menuList.appendChild(option);
53
+ menuList.appendChild(option);
64
-
54
+
65
55
  foodMenu[selectGenre].forEach( menu => {
66
56
  let option = document.createElement('option');
67
57
  option.innerHTML = menu;
68
- menuList.appendChild(option);
58
+ menuList.appendChild(option);
69
- });
59
+ });
70
60
  }
71
-
61
+ </script>
72
-
62
+ <select name="menuList" id="menuList" disabled>
63
+ <option disabled selected>料理を選択してください</option>
64
+ </select>
65
+ </body>
66
+ </html>
73
67
  ### 試したこと
74
68
 
75
69
  ここに問題に対して試したことを記載してください。
76
70
 
77
71
  ### 補足情報(FW/ツールのバージョンなど)
78
72
 
73
+
79
74
  ここにより詳細な情報を記載してください。