質問編集履歴

1

全体のコードの掲載

2019/10/20 09:13

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -97,3 +97,269 @@
97
97
  </div>
98
98
 
99
99
  ```
100
+
101
+
102
+
103
+ ### ページ全体のコード
104
+
105
+ ```html
106
+
107
+ <!DOCTYPE html>
108
+
109
+ <html lang="ja">
110
+
111
+ <head>
112
+
113
+ <meta charset="UTF-8">
114
+
115
+ <meta name="viewport" content="width=device-width, initial-scale=1">
116
+
117
+ <title>title</title>
118
+
119
+ </head>
120
+
121
+
122
+
123
+ <body>
124
+
125
+ <!-- <meta name="Description" content=""> -->
126
+
127
+ <div id="formWrap">
128
+
129
+ <h2 class="center">タイトル</h2>
130
+
131
+ <p>説明文</p>
132
+
133
+ <form method="POST" action="check.php">
134
+
135
+ <table class="formTable" bgcolor onload="functionName()">
136
+
137
+ <form name="formName" method="post" action="./pathToProgramFile"></form>
138
+
139
+ <tbody>
140
+
141
+ <tr>
142
+
143
+ <th>お名前 <span class="must">※必須</span></th>
144
+
145
+ <td><input size="25" type="text" name="name"></td>
146
+
147
+ </tr>
148
+
149
+ <tr>
150
+
151
+ </tr>
152
+
153
+ <div>
154
+
155
+ <form>
156
+
157
+ <select name="selectName1" onChange="functionName()">
158
+
159
+ <option value="jr-high">中学</option>
160
+
161
+ <option value="high">高校</option>
162
+
163
+ </select>
164
+
165
+
166
+
167
+ <!--選択肢その2(選択肢その1の項目によって変化)-->
168
+
169
+ <select name="selectName2"></select>
170
+
171
+ </form>
172
+
173
+ </div>
174
+
175
+
176
+
177
+ <script>
178
+
179
+ function functionName() {
180
+
181
+ var select1 = document.forms[0][0];
182
+
183
+ var select2 = document.forms[0][1];
184
+
185
+
186
+
187
+ select2.options.length = 0;
188
+
189
+
190
+
191
+ if (select1.options[select1.selectedIndex].value == "jr-high") {
192
+
193
+ select2.options[0] = new Option("1");
194
+
195
+ select2.options[1] = new Option("2");
196
+
197
+ select2.options[2] = new Option("3");
198
+
199
+ select2.options[3] = new Option("4");
200
+
201
+ select2.options[4] = new Option("5");
202
+
203
+ } else if (select1.options[select1.selectedIndex].value == "high") {
204
+
205
+ select2.options[0] = new Option("A");
206
+
207
+ select2.options[1] = new Option("B");
208
+
209
+ select2.options[2] = new Option("C");
210
+
211
+ select2.options[3] = new Option("D");
212
+
213
+ select2.options[4] = new Option("E");
214
+
215
+ select2.options[5] = new Option("F");
216
+
217
+ select2.options[6] = new Option("G");
218
+
219
+ select2.options[7] = new Option("H");
220
+
221
+ select2.options[8] = new Option("I");
222
+
223
+ select2.options[9] = new Option("J");
224
+
225
+ select2.options[10] = new Option("K");
226
+
227
+ select2.options[11] = new Option("L");
228
+
229
+ }
230
+
231
+ }
232
+
233
+ </script>
234
+
235
+
236
+
237
+
238
+
239
+ <style type="text/css">
240
+
241
+ #formWrap {
242
+
243
+ width:700px;
244
+
245
+ margin:0 auto;
246
+
247
+ color:#555;
248
+
249
+ line-height:120%;
250
+
251
+ font-size:90%;
252
+
253
+ }
254
+
255
+ table.formTable{
256
+
257
+ width:100%;
258
+
259
+ margin:0 auto;
260
+
261
+ border-collapse:collapse;
262
+
263
+ }
264
+
265
+ table.formTable td,table.formTable th{
266
+
267
+ border:1px solid #ccc;
268
+
269
+ padding:10px;
270
+
271
+ }
272
+
273
+ table.formTable th{
274
+
275
+ width:30%;
276
+
277
+ font-weight:normal;
278
+
279
+ background:#efefef;
280
+
281
+ text-align:left;
282
+
283
+ }
284
+
285
+ @media screen and (max-width:572px) {
286
+
287
+ #formWrap {
288
+
289
+ width:95%;
290
+
291
+ margin:0 auto;
292
+
293
+ }
294
+
295
+ table.formTable th, table.formTable td {
296
+
297
+ width:auto;
298
+
299
+ display:block;
300
+
301
+ }
302
+
303
+ table.formTable th {
304
+
305
+ margin-top:5px;
306
+
307
+ border-bottom:0;
308
+
309
+ }
310
+
311
+ input[type="text"], textarea {
312
+
313
+ width:80%;
314
+
315
+ padding:5px;
316
+
317
+ font-size:110%;
318
+
319
+ display:block;
320
+
321
+ }
322
+
323
+ input[type="submit"], input[type="reset"], input[type="button"] {
324
+
325
+ display:block;
326
+
327
+ width:100%;
328
+
329
+ height:40px;
330
+
331
+ }
332
+
333
+ }
334
+
335
+ .center{
336
+
337
+ text-align: center;
338
+
339
+ }
340
+
341
+
342
+
343
+ p{
344
+
345
+ text-align: center
346
+
347
+ }
348
+
349
+
350
+
351
+ .must{
352
+
353
+ color: red;
354
+
355
+ }
356
+
357
+
358
+
359
+ </style>
360
+
361
+ </body>
362
+
363
+ </html>
364
+
365
+ ```