質問編集履歴
2
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,152 +4,376 @@
|
|
4
4
|
|
5
5
|
|
6
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
|
-
<td>
|
52
|
-
|
53
|
-
<input type="text" class="price">
|
54
|
-
|
55
|
-
</td>
|
56
|
-
|
57
|
-
<td>
|
58
|
-
|
59
|
-
<select class="traffic">
|
60
|
-
|
61
|
-
<option value="0"></option>
|
62
|
-
|
63
|
-
<option value="1">片道</option>
|
64
|
-
|
65
|
-
<option value="2">往復</option>
|
66
|
-
|
67
|
-
</select>
|
68
|
-
|
69
|
-
</td>
|
70
|
-
|
71
|
-
<td>
|
72
|
-
|
73
|
-
<input type="text" class="total">
|
74
|
-
|
75
|
-
</td>
|
76
|
-
|
77
|
-
</tr>
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
<?php
|
82
|
-
|
83
|
-
$price = $_POST[‘price’];
|
84
|
-
|
85
|
-
$traffic = $_POST['traffic']
|
86
|
-
|
87
|
-
$total = $_POST['total'];
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
if ($price == "") {
|
92
|
-
|
93
|
-
echo "<span>※半角数字を入力してください</span>";
|
94
|
-
|
95
|
-
$price = ""; $traffic = "";
|
96
|
-
|
97
|
-
} else if ($traffic == "") {
|
98
|
-
|
99
|
-
echo "<span>※半角数字を入力してください</span>";
|
100
|
-
|
101
|
-
$price = ""; $traffic = "";
|
102
|
-
|
103
|
-
} else if (!is_numeric($price)){
|
104
|
-
|
105
|
-
echo "<span>※半角数字を入力してください</span>";
|
106
|
-
|
107
|
-
$price = ""; $traffic = "";
|
108
|
-
|
109
|
-
} else if (!is_numeric($b)) {
|
110
|
-
|
111
|
-
echo "<span>※半角数字を入力してください</span>";
|
112
|
-
|
113
|
-
$price = ""; $traffic = "";
|
114
|
-
|
115
|
-
}
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
Index0 = 0;
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
for(i = 0; i < 5; i++){
|
128
|
-
|
129
|
-
index0 += (price[i].value || 0) * (traffic[i].value || 0);
|
130
|
-
|
131
|
-
total[i].value = price[i].value == "" ? "" : ini_val;
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
}
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
?>
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
計算は
|
12
|
+
|
13
|
+
1(入力した数字)×(select)=(合計)
|
14
|
+
|
15
|
+
2(入力した数字)×(select)=(合計)
|
16
|
+
|
17
|
+
3(入力した数字)×(select)=(合計)
|
18
|
+
|
19
|
+
4(入力した数字)×(select)=(合計)
|
20
|
+
|
21
|
+
5(入力した数字)×(select)=(合計)
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
最後に5つの総合計を計算。
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
※下記のコードでは1つしか表示していないです。
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
今回やりたいこと
|
34
|
+
|
35
|
+
5つ計算させることと総合計を計算をしたい。また、コードを見やすくしたいと思っております。
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
試したこと
|
40
|
+
|
41
|
+
関数とfor文を使ってまとめようとしましたが、for文の中で計算させようと思いましたが、何度やってもうまくいかずに行き詰まってます。
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
HTML
|
48
|
+
|
49
|
+
|
140
50
|
|
141
51
|
```
|
142
52
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
53
|
+
<body>
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
<form method="GET" action="index2.php">
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
<fieldset>
|
62
|
+
|
63
|
+
<legend>交通費</legend>
|
64
|
+
|
65
|
+
<label>
|
66
|
+
|
67
|
+
<table>
|
68
|
+
|
69
|
+
<tr>
|
70
|
+
|
71
|
+
<th>交通機関</th>
|
72
|
+
|
73
|
+
<th>単価</th>
|
74
|
+
|
75
|
+
<th>利用区分</th>
|
76
|
+
|
77
|
+
<th>合計</th>
|
78
|
+
|
79
|
+
</tr>
|
80
|
+
|
81
|
+
<tr>
|
82
|
+
|
83
|
+
<td>
|
84
|
+
|
85
|
+
<select>
|
86
|
+
|
87
|
+
<option>地下鉄</option>
|
88
|
+
|
89
|
+
<option>JR来線</option>
|
90
|
+
|
91
|
+
</select>
|
92
|
+
|
93
|
+
</td>
|
94
|
+
|
95
|
+
<td>
|
96
|
+
|
97
|
+
<input type="text" name="price">
|
98
|
+
|
99
|
+
</td>
|
100
|
+
|
101
|
+
<td>
|
102
|
+
|
103
|
+
<select name="select">
|
104
|
+
|
105
|
+
<option value="0"></option>
|
106
|
+
|
107
|
+
<option value="1">片道</option>
|
108
|
+
|
109
|
+
<option value="2">往復</option>
|
110
|
+
|
111
|
+
</select>
|
112
|
+
|
113
|
+
</td>
|
114
|
+
|
115
|
+
<td>
|
116
|
+
|
117
|
+
<input type="text" name="total">
|
118
|
+
|
119
|
+
</td>
|
120
|
+
|
121
|
+
</tr>
|
122
|
+
|
123
|
+
<!-- <tr>
|
124
|
+
|
125
|
+
<td>
|
126
|
+
|
127
|
+
<select>
|
128
|
+
|
129
|
+
<option>地下鉄</option>
|
130
|
+
|
131
|
+
<option>JR来線</option>
|
132
|
+
|
133
|
+
</select>
|
134
|
+
|
135
|
+
</td>
|
136
|
+
|
137
|
+
<td>
|
138
|
+
|
139
|
+
<input type="text" name="price">
|
140
|
+
|
141
|
+
</td>
|
142
|
+
|
143
|
+
<td>
|
144
|
+
|
145
|
+
<select name="select">
|
146
|
+
|
147
|
+
<option value="0"></option>
|
148
|
+
|
149
|
+
<option value="1">片道</option>
|
150
|
+
|
151
|
+
<option value="2">往復</option>
|
152
|
+
|
153
|
+
</select>
|
154
|
+
|
155
|
+
</td>
|
156
|
+
|
157
|
+
<td>
|
158
|
+
|
159
|
+
<input type="text" name="total">
|
160
|
+
|
161
|
+
</td>
|
162
|
+
|
163
|
+
</tr>
|
164
|
+
|
165
|
+
<tr>
|
166
|
+
|
167
|
+
<td>
|
168
|
+
|
169
|
+
<select>
|
170
|
+
|
171
|
+
<option>地下鉄</option>
|
172
|
+
|
173
|
+
<option>JR来線</option>
|
174
|
+
|
175
|
+
</select>
|
176
|
+
|
177
|
+
</td>
|
178
|
+
|
179
|
+
<td>
|
180
|
+
|
181
|
+
<input type="text" name="price">
|
182
|
+
|
183
|
+
</td>
|
184
|
+
|
185
|
+
<td>
|
186
|
+
|
187
|
+
<select name="select">
|
188
|
+
|
189
|
+
<option value="0"></option>
|
190
|
+
|
191
|
+
<option value="1">片道</option>
|
192
|
+
|
193
|
+
<option value="2">往復</option>
|
194
|
+
|
195
|
+
</select>
|
196
|
+
|
197
|
+
</td>
|
198
|
+
|
199
|
+
<td>
|
200
|
+
|
201
|
+
<input type="text" name="total">
|
202
|
+
|
203
|
+
</td>
|
204
|
+
|
205
|
+
</tr>
|
206
|
+
|
207
|
+
<tr>
|
208
|
+
|
209
|
+
<td>
|
210
|
+
|
211
|
+
<select>
|
212
|
+
|
213
|
+
<option>地下鉄</option>
|
214
|
+
|
215
|
+
<option>JR来線</option>
|
216
|
+
|
217
|
+
</select>
|
218
|
+
|
219
|
+
</td>
|
220
|
+
|
221
|
+
<td>
|
222
|
+
|
223
|
+
<input type="text" name="price">
|
224
|
+
|
225
|
+
</td>
|
226
|
+
|
227
|
+
<td>
|
228
|
+
|
229
|
+
<select name="select">
|
230
|
+
|
231
|
+
<option value="0"></option>
|
232
|
+
|
233
|
+
<option value="1">片道</option>
|
234
|
+
|
235
|
+
<option value="2">往復</option>
|
236
|
+
|
237
|
+
</select>
|
238
|
+
|
239
|
+
</td>
|
240
|
+
|
241
|
+
<td>
|
242
|
+
|
243
|
+
<input type="text" name="total">
|
244
|
+
|
245
|
+
</td>
|
246
|
+
|
247
|
+
</tr>
|
248
|
+
|
249
|
+
<tr>
|
250
|
+
|
251
|
+
<td>
|
252
|
+
|
253
|
+
<select>
|
254
|
+
|
255
|
+
<option>地下鉄</option>
|
256
|
+
|
257
|
+
<option>JR来線</option>
|
258
|
+
|
259
|
+
</select>
|
260
|
+
|
261
|
+
</td>
|
262
|
+
|
263
|
+
<td>
|
264
|
+
|
265
|
+
<input type="text" name="price">
|
266
|
+
|
267
|
+
</td>
|
268
|
+
|
269
|
+
<td>
|
270
|
+
|
271
|
+
<select name="select">
|
272
|
+
|
273
|
+
<option value="0"></option>
|
274
|
+
|
275
|
+
<option value="1">片道</option>
|
276
|
+
|
277
|
+
<option value="2">往復</option>
|
278
|
+
|
279
|
+
</select>
|
280
|
+
|
281
|
+
</td>
|
282
|
+
|
283
|
+
<td>
|
284
|
+
|
285
|
+
<input type="text" name="total">
|
286
|
+
|
287
|
+
</td>
|
288
|
+
|
289
|
+
</tr> -->
|
290
|
+
|
291
|
+
</fieldset>
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
総合計<input type="text" name="all_total">
|
300
|
+
|
301
|
+
<button id="button">確認</button>
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
```
|
306
|
+
|
307
|
+
送信されたデータ
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
```
|
312
|
+
|
313
|
+
</body>
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
<body>
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
<?php
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
$price = $_REQUEST['price'];
|
326
|
+
|
327
|
+
$select = $_REQUEST['select'];
|
328
|
+
|
329
|
+
$total = $_REQUEST['total'];
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
$total = $select * $price;
|
334
|
+
|
335
|
+
?>
|
336
|
+
|
337
|
+
<form action="index.php" method="POST">
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
<select>
|
342
|
+
|
343
|
+
<option>地下鉄</option>
|
344
|
+
|
345
|
+
<option>JR来線</option>
|
346
|
+
|
347
|
+
</select>
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
<input type="text" name="price">
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
<select name="select">
|
356
|
+
|
357
|
+
<option value="0"></option>
|
358
|
+
|
359
|
+
<option value="1">片道</option>
|
360
|
+
|
361
|
+
<option value="2">往復</option>
|
362
|
+
|
363
|
+
</select>
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
<input type="text" name="total" value="<?php echo ("$total"); ?>">
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
<a href="index.php">送信</a>
|
372
|
+
|
373
|
+
</form>
|
374
|
+
|
375
|
+
</body>
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
```
|
1
test
CHANGED
File without changes
|
test
CHANGED
@@ -23,6 +23,8 @@
|
|
23
23
|
|
24
24
|
|
25
25
|
一部記載させていただきます。
|
26
|
+
|
27
|
+
```ここに言語を入力
|
26
28
|
|
27
29
|
|
28
30
|
|
@@ -136,6 +138,8 @@
|
|
136
138
|
|
137
139
|
?>
|
138
140
|
|
141
|
+
```
|
142
|
+
|
139
143
|
|
140
144
|
|
141
145
|
抜けてる所多いかもしれませんが、
|