質問編集履歴
7
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -46,496 +46,4 @@
|
|
46
46
|
|
47
47
|
|
48
48
|
|
49
|
-
function calc(){
|
50
|
-
|
51
|
-
// railsのビューファイルから、各入力・出力フォームのIDを取得している
|
52
|
-
|
53
|
-
const total_payment = document.getElementById("total-payment");
|
54
|
-
|
55
|
-
const total_people = document.getElementById("total-people");
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
const group_people_one = document.getElementById("group-people-one");
|
60
|
-
|
61
|
-
const group_price_one = document.getElementById("group-price-one");
|
62
|
-
|
63
|
-
const group_ratio_one = document.getElementById("group-ratio-one");
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
const group_people_two = document.getElementById("group-people-two");
|
68
|
-
|
69
|
-
const group_price_two = document.getElementById("group-price-two");
|
70
|
-
|
71
|
-
const group_ratio_two = document.getElementById("group-ratio-two");
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
const group_people_three = document.getElementById("group-people-three");
|
76
|
-
|
77
|
-
const group_price_three = document.getElementById("group-price-three");
|
78
|
-
|
79
|
-
const group_ratio_three = document.getElementById("group-ratio-three");
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
const indivisible_number = document.getElementById('indivisible-number');
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
// グループ2
|
88
|
-
|
89
|
-
group_ratio_two.addEventListener('keyup', () => {
|
90
|
-
|
91
|
-
const people_value = total_people.value;
|
92
|
-
|
93
|
-
const people_two_value = group_people_two.value;
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
const people_three_value = group_people_three.value;
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
const people = people_value - people_two_value - people_three_value;
|
102
|
-
|
103
|
-
group_people_one.textContent = people;
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
const payment_value = total_payment.value;
|
108
|
-
|
109
|
-
let price_two_value = group_price_two.value;
|
110
|
-
|
111
|
-
const price_three_value = group_price_three.value;
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
const payment = (payment_value - ((price_two_value * people_two_value) + (price_three_value * people_three_value))) / people;
|
116
|
-
|
117
|
-
const payment_cell = Math.ceil(payment/100)*100;
|
118
|
-
|
119
|
-
group_price_one.textContent = payment_cell ;
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
const ratio_two_value = group_ratio_two.value;
|
126
|
-
|
127
|
-
const ratio_two = ((ratio_two_value / 100) * payment_value) / people_two_value
|
128
|
-
|
129
|
-
const ratio_cell_two = Math.ceil(ratio_two/100)*100;
|
130
|
-
|
131
|
-
group_price_two.value = ratio_cell_two
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
const ratio_three_value = group_ratio_three.value;
|
136
|
-
|
137
|
-
group_ratio_one.textContent = 100 - ratio_three_value - ratio_two_value;
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
formula = (payment_cell * people) + (price_two_value * people_two_value) + (price_three_value * people_three_value);
|
144
|
-
|
145
|
-
indivisible_number.textContent = (formula - payment_value);
|
146
|
-
|
147
|
-
});
|
148
|
-
|
149
|
-
// グループ2
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
// グループ3
|
154
|
-
|
155
|
-
group_ratio_three.addEventListener('keyup', () => {
|
156
|
-
|
157
|
-
const people_value = total_people.value;
|
158
|
-
|
159
|
-
const people_two_value = group_people_two.value;
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
const people_three_value = group_people_three.value;
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
const people = people_value - people_two_value - people_three_value;
|
168
|
-
|
169
|
-
group_people_one.textContent = people;
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
const payment_value = total_payment.value;
|
174
|
-
|
175
|
-
const price_two_value = group_price_two.value;
|
176
|
-
|
177
|
-
const price_three_value = group_price_three.value;
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
const payment = (payment_value - ((price_two_value * people_two_value) + (price_three_value * people_three_value))) / people;
|
182
|
-
|
183
|
-
const payment_cell = Math.ceil(payment/100)*100;
|
184
|
-
|
185
|
-
group_price_one.textContent = payment_cell ;
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
const ratio_three_value = group_ratio_three.value;
|
190
|
-
|
191
|
-
const ratio_three = ((ratio_three_value / 100) * payment_value) / people_three_value
|
192
|
-
|
193
|
-
const ratio_cell_three = Math.ceil(ratio_three/100)*100;
|
194
|
-
|
195
|
-
group_price_three.value = ratio_cell_three
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
const ratio_two_value = group_ratio_two.value;
|
200
|
-
|
201
|
-
group_ratio_one.textContent = 100 - ratio_three_value - ratio_two_value;
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
formula = (payment_cell * people) + (price_two_value * people_two_value) + (price_three_value * people_three_value);
|
206
|
-
|
207
|
-
indivisible_number.textContent = (formula - payment_value);
|
208
|
-
|
209
|
-
});
|
210
|
-
|
211
|
-
// グループ3
|
212
|
-
|
213
|
-
}
|
214
|
-
|
215
|
-
window.addEventListener("load", calc);
|
216
|
-
|
217
49
|
```
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
```HTML
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
<!DOCTYPE html>
|
226
|
-
|
227
|
-
<html>
|
228
|
-
|
229
|
-
<head>
|
230
|
-
|
231
|
-
<title>SplitTheBill</title>
|
232
|
-
|
233
|
-
<meta name="csrf-param" content="authenticity_token" />
|
234
|
-
|
235
|
-
<meta name="csrf-token" content="gfsQI82k3BKLmAf7cBuuMNpe7vaTiaos8JvbM3hRXcNsxdaSupVkm70AJA+Jf3v2Bs+xl4F0d4roBmTtPrNkkw==" />
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
<link rel="stylesheet" media="all" href="/assets/calculations.self-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css?body=1" data-turbolinks-track="reload" />
|
242
|
-
|
243
|
-
<link rel="stylesheet" media="all" href="/assets/calculations/index.html.self-3d3c25769ab198a66e397d7d08478d8fe0bff2e27c6bf7b28e53cab28d7cba07.css?body=1" data-turbolinks-track="reload" />
|
244
|
-
|
245
|
-
<link rel="stylesheet" media="all" href="/assets/application.self-f0d704deea029cf000697e2c0181ec173a1b474645466ed843eb5ee7bb215794.css?body=1" data-turbolinks-track="reload" />
|
246
|
-
|
247
|
-
<script src="/packs/js/application-cedbf28281aaf375c93f.js" data-turbolinks-track="reload"></script>
|
248
|
-
|
249
|
-
</head>
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
<body>
|
254
|
-
|
255
|
-
<div class="calc-contents">
|
256
|
-
|
257
|
-
<header class="calc-header">
|
258
|
-
|
259
|
-
</header>
|
260
|
-
|
261
|
-
<div class="calc-main">
|
262
|
-
|
263
|
-
<form action="/" accept-charset="UTF-8" method="post"><input type="hidden" name="authenticity_token" value="3ynDmPLH1QMQiOCAvMa0M4v1Se71JYvnAHIcRrwYcAjjEsRrUxxVypaw0o6pWcp7qd7MVavoDXPlmJNyjyUm1w==" />
|
264
|
-
|
265
|
-
<div class="calc-title-one">情報を入力</div>
|
266
|
-
|
267
|
-
<div class="total">
|
268
|
-
|
269
|
-
<div class="total-payment">
|
270
|
-
|
271
|
-
<span>総支払額</span>
|
272
|
-
|
273
|
-
<span class="indispensable">※</span>
|
274
|
-
|
275
|
-
<input class="total-people" id="total-payment" placeholder="例)50000" type="text" name="hoge" />円
|
276
|
-
|
277
|
-
</div>
|
278
|
-
|
279
|
-
<div class="total-people">
|
280
|
-
|
281
|
-
<span>総人数</span>
|
282
|
-
|
283
|
-
<span class="indispensable">※</span>
|
284
|
-
|
285
|
-
<input class="total-people" id="total-people" placeholder="例)5" type="text" name="hoge" />人
|
286
|
-
|
287
|
-
</div>
|
288
|
-
|
289
|
-
</div>
|
290
|
-
|
291
|
-
<div class="calc-title-two">計算を入力</div>
|
292
|
-
|
293
|
-
<div class="calc-description">グループ2以降から数値を入力してください。<span class="indispensable-description">※は必須項目です。</span></div>
|
294
|
-
|
295
|
-
<div class="calc-description">比率か一人当たりの金額どちらか一方を記入すれば、もう一方が自動で表示されます。</div>
|
296
|
-
|
297
|
-
<div class="description_one">グループ1には、総額・総人数からグループ2以降の値を引いた数値が表示されます。</div>
|
298
|
-
|
299
|
-
<div class ="description">一人あたりの支払額は十の位で切り上げを行うため、あまりが生じます。</div>
|
300
|
-
|
301
|
-
<div class="description_two">比率は小数点第二位で切り捨てを行なっています。</div>
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
<div class="group">
|
310
|
-
|
311
|
-
<div class="group-text">
|
312
|
-
|
313
|
-
<span class="group-name"> グループ名</span>
|
314
|
-
|
315
|
-
</div>
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
<div class="group">
|
320
|
-
|
321
|
-
<div class="group-text">
|
322
|
-
|
323
|
-
<span>人数</span>
|
324
|
-
|
325
|
-
</div>
|
326
|
-
|
327
|
-
</div>
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
<div class="group">
|
332
|
-
|
333
|
-
<div class="group-text">
|
334
|
-
|
335
|
-
<span>比率</span>
|
336
|
-
|
337
|
-
</div>
|
338
|
-
|
339
|
-
</div>
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
<div class="group">
|
344
|
-
|
345
|
-
<div class="group-text">
|
346
|
-
|
347
|
-
<span>一人あたり</span>
|
348
|
-
|
349
|
-
</div>
|
350
|
-
|
351
|
-
</div>
|
352
|
-
|
353
|
-
</div>
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
<div class="group">
|
360
|
-
|
361
|
-
<div class="group-text">
|
362
|
-
|
363
|
-
<span class="group-name"></span>
|
364
|
-
|
365
|
-
<input class="group-input-name" id="group-name-one" placeholder="例)グループ1" type="text" name="hoge" />
|
366
|
-
|
367
|
-
</div>
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
<div class="group">
|
372
|
-
|
373
|
-
<div class="group-text-one">
|
374
|
-
|
375
|
-
<span id='group-people-one'></span>
|
376
|
-
|
377
|
-
<span class = "unit">人</span>
|
378
|
-
|
379
|
-
</div>
|
380
|
-
|
381
|
-
</div>
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
<div class="group">
|
386
|
-
|
387
|
-
<div class="group-text-one">
|
388
|
-
|
389
|
-
<span id='group-ratio-one'></span>
|
390
|
-
|
391
|
-
<span class = "unit"> %</span>
|
392
|
-
|
393
|
-
</div>
|
394
|
-
|
395
|
-
</div>
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
<div class="group">
|
400
|
-
|
401
|
-
<div class="group-text-one">
|
402
|
-
|
403
|
-
<span id='group-price-one'></span>
|
404
|
-
|
405
|
-
<span class = "unit"> 円</span>
|
406
|
-
|
407
|
-
</div>
|
408
|
-
|
409
|
-
</div>
|
410
|
-
|
411
|
-
</div>
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
<div class="group">
|
418
|
-
|
419
|
-
<div class="group-text">
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
<input class="group-input-name" id="group-name-two" placeholder="例)グループ2" type="text" name="hoge" />
|
424
|
-
|
425
|
-
</div>
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
<div class="group-text">
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
<span class="indispensable">※</span>
|
434
|
-
|
435
|
-
<input class="group-input" id="group-people-two" placeholder="例)1" type="text" name="hoge" />人
|
436
|
-
|
437
|
-
</div>
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
<div class="group-text">
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
<span class="indispensable">※</span>
|
446
|
-
|
447
|
-
<input class="group-input" id="group-ratio-two" placeholder="例)10" type="text" name="hoge" />%
|
448
|
-
|
449
|
-
</div>
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
<div class="group-text">
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
<span class="indispensable">※</span>
|
458
|
-
|
459
|
-
<input class="group-input" id="group-price-two" placeholder="例)10000" type="text" name="hoge" />円
|
460
|
-
|
461
|
-
</div>
|
462
|
-
|
463
|
-
</div>
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
<div class="group">
|
468
|
-
|
469
|
-
<div class="group-text">
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
<input class="group-input-name" id="group-name-three" placeholder="例)グループ3" type="text" name="hoge" />
|
474
|
-
|
475
|
-
</div>
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
<div class="group-text">
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
<span class="indispensable">※</span>
|
484
|
-
|
485
|
-
<input class="group-input" id="group-people-three" placeholder="例)1" type="text" name="hoge" />人
|
486
|
-
|
487
|
-
</div>
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
<div class="group-text">
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
<span class="indispensable">※</span>
|
496
|
-
|
497
|
-
<input class="group-input" id="group-ratio-three" placeholder="例)10" type="text" name="hoge" />%
|
498
|
-
|
499
|
-
</div>
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
<div class="group-text">
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
<span class="indispensable">※</span>
|
510
|
-
|
511
|
-
<input class="group-input" id="group-price-three" placeholder="例)10000" type="text" name="hoge" />円
|
512
|
-
|
513
|
-
</div>
|
514
|
-
|
515
|
-
</div>
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
<div class="group-invisible">
|
520
|
-
|
521
|
-
<div class="indivisible-number">
|
522
|
-
|
523
|
-
<span>あまり</span>
|
524
|
-
|
525
|
-
<span id='indivisible-number'></span>円
|
526
|
-
|
527
|
-
</div>
|
528
|
-
|
529
|
-
</div>
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
</form></div>
|
534
|
-
|
535
|
-
</body>
|
536
|
-
|
537
|
-
</html>
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
```
|
6
若葉マークの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -8,6 +8,8 @@
|
|
8
8
|
|
9
9
|
|
10
10
|
|
11
|
+
|
12
|
+
|
11
13
|
### 発生している問題・エラーメッセージ
|
12
14
|
|
13
15
|
一度目は思った通りの処理が動きます。
|
5
HTMLの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,8 +22,6 @@
|
|
22
22
|
|
23
23
|
**今回数字が変わってしまうのは下記コードのprice_two_valueの部分です。**
|
24
24
|
|
25
|
-
(ちなみにブラウザ上で数字に異変が起きるのはgroup_price_oneの方でした。console.logを用いてgroup_price_oneを出力するための計算式に含まれている数を一つ一つ確認したところ、price_two_valueが見た目は変わらないのに中身の数字が変化してしまっていると分かりました。)
|
26
|
-
|
27
25
|
|
28
26
|
|
29
27
|
**例えば入力フォームに「30」と入力したら、当然ですが、その30をもとに計算出力したいです。
|
@@ -38,66 +36,8 @@
|
|
38
36
|
|
39
37
|
|
40
38
|
|
41
|
-
記述やイベント発火させようとしているフォームが多いため、
|
42
|
-
|
43
|
-
今回はそのエラーが起きる部分のイベント発火の部分のみ記載します。
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
その他のフォーム・イベント発火にも関連して問題がありそうな場合、追記しますので教えていただけますでしょうか。
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
どうぞよろしくお願いいたします。
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
39
|
### 該当のソースコード
|
60
40
|
|
61
|
-
前提として、今回作成中のアプリは割勘計算機能です。
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
total_payment(総支払額)とtotal_people(総人数)は前提条件のようなもので、このフォームに入力された値をもとに、様々な計算を行います。
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
そのほかにグループを三つ用意しています。
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
group_people_two、group_price_two、group_ratio_two
|
74
|
-
|
75
|
-
上記はグループ2の、左から順に人数、料金、比率の値を入れていくフォームです。
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
group_people_three、group_price_three、group_ratio_three
|
80
|
-
|
81
|
-
上記はグループ3です。
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
group_people_one、group_price_one、group_ratio_one
|
86
|
-
|
87
|
-
上記はグループ1ですが、グループ1のみ入力フォームではなく出力するために用意しています。
|
88
|
-
|
89
|
-
前提条件からグループ2と3の数値を引いて、グループ1に表示させようとしています。
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
price(料金)とratio(比率)に関しては、一方に値を入れた時、もう一方の値が自動で表示されるようにしています。
|
94
|
-
|
95
|
-
この部分で、今回の問題が発生しています。
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
indivisible_numberは余った値を出力しようとしています。
|
100
|
-
|
101
41
|
|
102
42
|
|
103
43
|
```JavaScript
|
@@ -278,7 +218,39 @@
|
|
278
218
|
|
279
219
|
```HTML
|
280
220
|
|
221
|
+
|
222
|
+
|
223
|
+
<!DOCTYPE html>
|
224
|
+
|
225
|
+
<html>
|
226
|
+
|
227
|
+
<head>
|
228
|
+
|
229
|
+
<title>SplitTheBill</title>
|
230
|
+
|
231
|
+
<meta name="csrf-param" content="authenticity_token" />
|
232
|
+
|
233
|
+
<meta name="csrf-token" content="gfsQI82k3BKLmAf7cBuuMNpe7vaTiaos8JvbM3hRXcNsxdaSupVkm70AJA+Jf3v2Bs+xl4F0d4roBmTtPrNkkw==" />
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
<link rel="stylesheet" media="all" href="/assets/calculations.self-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css?body=1" data-turbolinks-track="reload" />
|
240
|
+
|
241
|
+
<link rel="stylesheet" media="all" href="/assets/calculations/index.html.self-3d3c25769ab198a66e397d7d08478d8fe0bff2e27c6bf7b28e53cab28d7cba07.css?body=1" data-turbolinks-track="reload" />
|
242
|
+
|
243
|
+
<link rel="stylesheet" media="all" href="/assets/application.self-f0d704deea029cf000697e2c0181ec173a1b474645466ed843eb5ee7bb215794.css?body=1" data-turbolinks-track="reload" />
|
244
|
+
|
245
|
+
<script src="/packs/js/application-cedbf28281aaf375c93f.js" data-turbolinks-track="reload"></script>
|
246
|
+
|
247
|
+
</head>
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
<body>
|
252
|
+
|
281
|
-
<div class="calc-contents">
|
253
|
+
<div class="calc-contents">
|
282
254
|
|
283
255
|
<header class="calc-header">
|
284
256
|
|
@@ -286,7 +258,7 @@
|
|
286
258
|
|
287
259
|
<div class="calc-main">
|
288
260
|
|
289
|
-
<
|
261
|
+
<form action="/" accept-charset="UTF-8" method="post"><input type="hidden" name="authenticity_token" value="3ynDmPLH1QMQiOCAvMa0M4v1Se71JYvnAHIcRrwYcAjjEsRrUxxVypaw0o6pWcp7qd7MVavoDXPlmJNyjyUm1w==" />
|
290
262
|
|
291
263
|
<div class="calc-title-one">情報を入力</div>
|
292
264
|
|
@@ -298,7 +270,7 @@
|
|
298
270
|
|
299
271
|
<span class="indispensable">※</span>
|
300
272
|
|
301
|
-
<
|
273
|
+
<input class="total-people" id="total-payment" placeholder="例)50000" type="text" name="hoge" />円
|
302
274
|
|
303
275
|
</div>
|
304
276
|
|
@@ -308,7 +280,7 @@
|
|
308
280
|
|
309
281
|
<span class="indispensable">※</span>
|
310
282
|
|
311
|
-
<
|
283
|
+
<input class="total-people" id="total-people" placeholder="例)5" type="text" name="hoge" />人
|
312
284
|
|
313
285
|
</div>
|
314
286
|
|
@@ -322,17 +294,63 @@
|
|
322
294
|
|
323
295
|
<div class="description_one">グループ1には、総額・総人数からグループ2以降の値を引いた数値が表示されます。</div>
|
324
296
|
|
325
|
-
<div class ="description
|
297
|
+
<div class ="description">一人あたりの支払額は十の位で切り上げを行うため、あまりが生じます。</div>
|
326
|
-
|
298
|
+
|
327
|
-
<div class="description_o
|
299
|
+
<div class="description_two">比率は小数点第二位で切り捨てを行なっています。</div>
|
328
300
|
|
329
301
|
|
330
302
|
|
331
303
|
|
332
304
|
|
305
|
+
|
306
|
+
|
307
|
+
<div class="group">
|
308
|
+
|
309
|
+
<div class="group-text">
|
310
|
+
|
311
|
+
<span class="group-name"> グループ名</span>
|
312
|
+
|
333
|
-
|
313
|
+
</div>
|
314
|
+
|
315
|
+
|
316
|
+
|
334
|
-
|
317
|
+
<div class="group">
|
318
|
+
|
319
|
+
<div class="group-text">
|
320
|
+
|
321
|
+
<span>人数</span>
|
322
|
+
|
335
|
-
|
323
|
+
</div>
|
324
|
+
|
325
|
+
</div>
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
<div class="group">
|
330
|
+
|
331
|
+
<div class="group-text">
|
332
|
+
|
333
|
+
<span>比率</span>
|
334
|
+
|
335
|
+
</div>
|
336
|
+
|
337
|
+
</div>
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
<div class="group">
|
342
|
+
|
343
|
+
<div class="group-text">
|
344
|
+
|
345
|
+
<span>一人あたり</span>
|
346
|
+
|
347
|
+
</div>
|
348
|
+
|
349
|
+
</div>
|
350
|
+
|
351
|
+
</div>
|
352
|
+
|
353
|
+
|
336
354
|
|
337
355
|
|
338
356
|
|
@@ -340,9 +358,9 @@
|
|
340
358
|
|
341
359
|
<div class="group-text">
|
342
360
|
|
343
|
-
<span class="group-name">
|
361
|
+
<span class="group-name"></span>
|
344
|
-
|
362
|
+
|
345
|
-
<
|
363
|
+
<input class="group-input-name" id="group-name-one" placeholder="例)グループ1" type="text" name="hoge" />
|
346
364
|
|
347
365
|
</div>
|
348
366
|
|
@@ -352,9 +370,9 @@
|
|
352
370
|
|
353
371
|
<div class="group-text-one">
|
354
372
|
|
355
|
-
<span>人数</span>
|
356
|
-
|
357
|
-
<span id='group-people-one'></span>
|
373
|
+
<span id='group-people-one'></span>
|
374
|
+
|
375
|
+
<span class = "unit">人</span>
|
358
376
|
|
359
377
|
</div>
|
360
378
|
|
@@ -366,9 +384,9 @@
|
|
366
384
|
|
367
385
|
<div class="group-text-one">
|
368
386
|
|
369
|
-
<span>比率</span>
|
370
|
-
|
371
|
-
<span id='group-ratio-one'></span>
|
387
|
+
<span id='group-ratio-one'></span>
|
388
|
+
|
389
|
+
<span class = "unit"> %</span>
|
372
390
|
|
373
391
|
</div>
|
374
392
|
|
@@ -380,9 +398,9 @@
|
|
380
398
|
|
381
399
|
<div class="group-text-one">
|
382
400
|
|
383
|
-
<span>一人あたり</span>
|
384
|
-
|
385
|
-
<span id='group-price-one'></span>
|
401
|
+
<span id='group-price-one'></span>
|
402
|
+
|
403
|
+
<span class = "unit"> 円</span>
|
386
404
|
|
387
405
|
</div>
|
388
406
|
|
@@ -392,97 +410,89 @@
|
|
392
410
|
|
393
411
|
|
394
412
|
|
395
|
-
|
413
|
+
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
<%# グループ2 %>
|
400
414
|
|
401
415
|
<div class="group">
|
402
416
|
|
403
417
|
<div class="group-text">
|
404
418
|
|
405
|
-
|
419
|
+
|
406
|
-
|
420
|
+
|
407
|
-
<
|
421
|
+
<input class="group-input-name" id="group-name-two" placeholder="例)グループ2" type="text" name="hoge" />
|
408
|
-
|
422
|
+
|
409
|
-
</div>
|
423
|
+
</div>
|
410
|
-
|
411
|
-
|
412
|
-
|
424
|
+
|
425
|
+
|
426
|
+
|
413
|
-
<div class="group-text">
|
427
|
+
<div class="group-text">
|
414
|
-
|
415
|
-
|
428
|
+
|
429
|
+
|
416
430
|
|
417
431
|
<span class="indispensable">※</span>
|
418
432
|
|
419
|
-
<
|
433
|
+
<input class="group-input" id="group-people-two" placeholder="例)1" type="text" name="hoge" />人
|
420
|
-
|
434
|
+
|
421
|
-
</div>
|
435
|
+
</div>
|
422
|
-
|
423
|
-
|
424
|
-
|
436
|
+
|
437
|
+
|
438
|
+
|
425
|
-
<div class="group-text">
|
439
|
+
<div class="group-text">
|
426
|
-
|
427
|
-
|
440
|
+
|
441
|
+
|
428
442
|
|
429
443
|
<span class="indispensable">※</span>
|
430
444
|
|
431
|
-
<
|
445
|
+
<input class="group-input" id="group-ratio-two" placeholder="例)10" type="text" name="hoge" />%
|
432
|
-
|
446
|
+
|
433
|
-
</div>
|
447
|
+
</div>
|
434
|
-
|
435
|
-
|
436
|
-
|
448
|
+
|
449
|
+
|
450
|
+
|
437
|
-
<div class="group-text">
|
451
|
+
<div class="group-text">
|
438
|
-
|
439
|
-
|
452
|
+
|
453
|
+
|
440
454
|
|
441
455
|
<span class="indispensable">※</span>
|
442
456
|
|
443
|
-
<
|
457
|
+
<input class="group-input" id="group-price-two" placeholder="例)10000" type="text" name="hoge" />円
|
444
458
|
|
445
459
|
</div>
|
446
460
|
|
447
461
|
</div>
|
448
462
|
|
449
|
-
|
463
|
+
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
<%# グループ3 %>
|
454
464
|
|
455
465
|
<div class="group">
|
456
466
|
|
457
467
|
<div class="group-text">
|
458
468
|
|
459
|
-
|
469
|
+
|
460
|
-
|
470
|
+
|
461
|
-
<
|
471
|
+
<input class="group-input-name" id="group-name-three" placeholder="例)グループ3" type="text" name="hoge" />
|
462
|
-
|
472
|
+
|
463
|
-
</div>
|
473
|
+
</div>
|
464
|
-
|
465
|
-
|
466
|
-
|
474
|
+
|
475
|
+
|
476
|
+
|
467
|
-
<div class="group-text">
|
477
|
+
<div class="group-text">
|
468
|
-
|
469
|
-
|
478
|
+
|
479
|
+
|
470
480
|
|
471
481
|
<span class="indispensable">※</span>
|
472
482
|
|
473
|
-
<
|
483
|
+
<input class="group-input" id="group-people-three" placeholder="例)1" type="text" name="hoge" />人
|
474
|
-
|
484
|
+
|
475
|
-
</div>
|
485
|
+
</div>
|
476
|
-
|
477
|
-
|
478
|
-
|
486
|
+
|
487
|
+
|
488
|
+
|
479
|
-
<div class="group-text">
|
489
|
+
<div class="group-text">
|
480
|
-
|
481
|
-
|
490
|
+
|
491
|
+
|
482
492
|
|
483
493
|
<span class="indispensable">※</span>
|
484
494
|
|
485
|
-
<
|
495
|
+
<input class="group-input" id="group-ratio-three" placeholder="例)10" type="text" name="hoge" />%
|
486
496
|
|
487
497
|
</div>
|
488
498
|
|
@@ -492,18 +502,16 @@
|
|
492
502
|
|
493
503
|
<div class="group-text">
|
494
504
|
|
495
|
-
|
505
|
+
|
496
506
|
|
497
507
|
<span class="indispensable">※</span>
|
498
508
|
|
499
|
-
<
|
509
|
+
<input class="group-input" id="group-price-three" placeholder="例)10000" type="text" name="hoge" />円
|
500
510
|
|
501
511
|
</div>
|
502
512
|
|
503
513
|
</div>
|
504
514
|
|
505
|
-
<%# グループ3 %>
|
506
|
-
|
507
515
|
|
508
516
|
|
509
517
|
<div class="group-invisible">
|
@@ -518,12 +526,14 @@
|
|
518
526
|
|
519
527
|
</div>
|
520
528
|
|
521
|
-
<%# /販売価格 %>
|
522
|
-
|
523
529
|
|
524
530
|
|
525
|
-
|
531
|
+
</form></div>
|
526
|
-
|
532
|
+
|
527
|
-
</d
|
533
|
+
</body>
|
534
|
+
|
535
|
+
</html>
|
536
|
+
|
537
|
+
|
528
538
|
|
529
539
|
```
|
4
誤って削除した部分の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -104,6 +104,44 @@
|
|
104
104
|
|
105
105
|
|
106
106
|
|
107
|
+
function calc(){
|
108
|
+
|
109
|
+
// railsのビューファイルから、各入力・出力フォームのIDを取得している
|
110
|
+
|
111
|
+
const total_payment = document.getElementById("total-payment");
|
112
|
+
|
113
|
+
const total_people = document.getElementById("total-people");
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
const group_people_one = document.getElementById("group-people-one");
|
118
|
+
|
119
|
+
const group_price_one = document.getElementById("group-price-one");
|
120
|
+
|
121
|
+
const group_ratio_one = document.getElementById("group-ratio-one");
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
const group_people_two = document.getElementById("group-people-two");
|
126
|
+
|
127
|
+
const group_price_two = document.getElementById("group-price-two");
|
128
|
+
|
129
|
+
const group_ratio_two = document.getElementById("group-ratio-two");
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
const group_people_three = document.getElementById("group-people-three");
|
134
|
+
|
135
|
+
const group_price_three = document.getElementById("group-price-three");
|
136
|
+
|
137
|
+
const group_ratio_three = document.getElementById("group-ratio-three");
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
const indivisible_number = document.getElementById('indivisible-number');
|
142
|
+
|
143
|
+
|
144
|
+
|
107
145
|
// グループ2
|
108
146
|
|
109
147
|
group_ratio_two.addEventListener('keyup', () => {
|
@@ -230,6 +268,10 @@
|
|
230
268
|
|
231
269
|
// グループ3
|
232
270
|
|
271
|
+
}
|
272
|
+
|
273
|
+
window.addEventListener("load", calc);
|
274
|
+
|
233
275
|
```
|
234
276
|
|
235
277
|
|
3
グループ3のイベント発火の記述を追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -104,354 +104,384 @@
|
|
104
104
|
|
105
105
|
|
106
106
|
|
107
|
+
// グループ2
|
108
|
+
|
107
|
-
|
109
|
+
group_ratio_two.addEventListener('keyup', () => {
|
110
|
+
|
108
|
-
|
111
|
+
const people_value = total_people.value;
|
112
|
+
|
113
|
+
const people_two_value = group_people_two.value;
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
const people_three_value = group_people_three.value;
|
118
|
+
|
119
|
+
|
120
|
+
|
109
|
-
const
|
121
|
+
const people = people_value - people_two_value - people_three_value;
|
122
|
+
|
123
|
+
group_people_one.textContent = people;
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
const payment_value = total_payment.value;
|
128
|
+
|
129
|
+
let price_two_value = group_price_two.value;
|
130
|
+
|
131
|
+
const price_three_value = group_price_three.value;
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
const payment = (payment_value - ((price_two_value * people_two_value) + (price_three_value * people_three_value))) / people;
|
136
|
+
|
137
|
+
const payment_cell = Math.ceil(payment/100)*100;
|
138
|
+
|
139
|
+
group_price_one.textContent = payment_cell ;
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
const ratio_two_value = group_ratio_two.value;
|
146
|
+
|
147
|
+
const ratio_two = ((ratio_two_value / 100) * payment_value) / people_two_value
|
148
|
+
|
149
|
+
const ratio_cell_two = Math.ceil(ratio_two/100)*100;
|
150
|
+
|
151
|
+
group_price_two.value = ratio_cell_two
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
const ratio_three_value = group_ratio_three.value;
|
156
|
+
|
157
|
+
group_ratio_one.textContent = 100 - ratio_three_value - ratio_two_value;
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
formula = (payment_cell * people) + (price_two_value * people_two_value) + (price_three_value * people_three_value);
|
164
|
+
|
165
|
+
indivisible_number.textContent = (formula - payment_value);
|
166
|
+
|
167
|
+
});
|
168
|
+
|
169
|
+
// グループ2
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
// グループ3
|
174
|
+
|
175
|
+
group_ratio_three.addEventListener('keyup', () => {
|
176
|
+
|
177
|
+
const people_value = total_people.value;
|
178
|
+
|
179
|
+
const people_two_value = group_people_two.value;
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
const people_three_value = group_people_three.value;
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
const people = people_value - people_two_value - people_three_value;
|
188
|
+
|
189
|
+
group_people_one.textContent = people;
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
const payment_value = total_payment.value;
|
194
|
+
|
195
|
+
const price_two_value = group_price_two.value;
|
196
|
+
|
197
|
+
const price_three_value = group_price_three.value;
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
const payment = (payment_value - ((price_two_value * people_two_value) + (price_three_value * people_three_value))) / people;
|
202
|
+
|
203
|
+
const payment_cell = Math.ceil(payment/100)*100;
|
204
|
+
|
205
|
+
group_price_one.textContent = payment_cell ;
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
const ratio_three_value = group_ratio_three.value;
|
210
|
+
|
211
|
+
const ratio_three = ((ratio_three_value / 100) * payment_value) / people_three_value
|
212
|
+
|
213
|
+
const ratio_cell_three = Math.ceil(ratio_three/100)*100;
|
214
|
+
|
215
|
+
group_price_three.value = ratio_cell_three
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
const ratio_two_value = group_ratio_two.value;
|
220
|
+
|
221
|
+
group_ratio_one.textContent = 100 - ratio_three_value - ratio_two_value;
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
formula = (payment_cell * people) + (price_two_value * people_two_value) + (price_three_value * people_three_value);
|
226
|
+
|
227
|
+
indivisible_number.textContent = (formula - payment_value);
|
228
|
+
|
229
|
+
});
|
230
|
+
|
231
|
+
// グループ3
|
232
|
+
|
233
|
+
```
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
```HTML
|
238
|
+
|
239
|
+
<div class="calc-contents">
|
240
|
+
|
241
|
+
<header class="calc-header">
|
242
|
+
|
243
|
+
</header>
|
244
|
+
|
245
|
+
<div class="calc-main">
|
246
|
+
|
247
|
+
<%= form_with local: true do |f| %>
|
248
|
+
|
249
|
+
<div class="calc-title-one">情報を入力</div>
|
250
|
+
|
251
|
+
<div class="total">
|
252
|
+
|
253
|
+
<div class="total-payment">
|
254
|
+
|
255
|
+
<span>総支払額</span>
|
256
|
+
|
257
|
+
<span class="indispensable">※</span>
|
258
|
+
|
259
|
+
<%= f.text_field :hoge, class:"total-people", id:"total-payment", placeholder:"例)50000" %>円
|
260
|
+
|
261
|
+
</div>
|
262
|
+
|
263
|
+
<div class="total-people">
|
264
|
+
|
265
|
+
<span>総人数</span>
|
266
|
+
|
267
|
+
<span class="indispensable">※</span>
|
268
|
+
|
269
|
+
<%= f.text_field :hoge, class:"total-people", id:"total-people", placeholder:"例)5" %>人
|
270
|
+
|
271
|
+
</div>
|
272
|
+
|
273
|
+
</div>
|
274
|
+
|
275
|
+
<div class="calc-title-two">計算を入力</div>
|
276
|
+
|
277
|
+
<div class="calc-description">グループ2以降から数値を入力してください。<span class="indispensable-description">※は必須項目です。</span></div>
|
278
|
+
|
279
|
+
<div class="calc-description">比率か一人当たりの金額どちらか一方を記入すれば、もう一方が自動で表示されます。</div>
|
280
|
+
|
281
|
+
<div class="description_one">グループ1には、総額・総人数からグループ2以降の値を引いた数値が表示されます。</div>
|
282
|
+
|
283
|
+
<div class ="description_two">10の位で切り上げを行うため、あまりが生じます。</div>
|
284
|
+
|
285
|
+
<div class="description_one">比率は小数点二位で切り捨てを行なっています。</div>
|
286
|
+
|
287
|
+
|
110
288
|
|
111
289
|
|
112
290
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
c
|
146
|
-
|
147
|
-
c
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
co
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
c
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
291
|
+
<%# 販売価格 %>
|
292
|
+
|
293
|
+
<%# グループ1 %>
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
<div class="group">
|
298
|
+
|
299
|
+
<div class="group-text">
|
300
|
+
|
301
|
+
<span class="group-name"> グループ名</span>
|
302
|
+
|
303
|
+
<%= f.text_field :hoge, class:"group-input-name", id:"group-name-one", placeholder:"例)グループ1" %>
|
304
|
+
|
305
|
+
</div>
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
<div class="group">
|
310
|
+
|
311
|
+
<div class="group-text-one">
|
312
|
+
|
313
|
+
<span>人数</span>
|
314
|
+
|
315
|
+
<span id='group-people-one'></span>人
|
316
|
+
|
317
|
+
</div>
|
318
|
+
|
319
|
+
</div>
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
<div class="group">
|
324
|
+
|
325
|
+
<div class="group-text-one">
|
326
|
+
|
327
|
+
<span>比率</span>
|
328
|
+
|
329
|
+
<span id='group-ratio-one'></span>%
|
330
|
+
|
331
|
+
</div>
|
332
|
+
|
333
|
+
</div>
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
<div class="group">
|
338
|
+
|
339
|
+
<div class="group-text-one">
|
340
|
+
|
341
|
+
<span>一人あたり</span>
|
342
|
+
|
343
|
+
<span id='group-price-one'></span>円
|
344
|
+
|
345
|
+
</div>
|
346
|
+
|
347
|
+
</div>
|
348
|
+
|
349
|
+
</div>
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
<%# グループ1 %>
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
<%# グループ2 %>
|
358
|
+
|
359
|
+
<div class="group">
|
360
|
+
|
361
|
+
<div class="group-text">
|
362
|
+
|
363
|
+
<span>グループ名</span>
|
364
|
+
|
365
|
+
<%= f.text_field :hoge, class:"group-input-name", id:"group-name-two", placeholder:"例)グループ2" %>
|
366
|
+
|
367
|
+
</div>
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
<div class="group-text">
|
372
|
+
|
373
|
+
<span>人数</span>
|
374
|
+
|
375
|
+
<span class="indispensable">※</span>
|
376
|
+
|
377
|
+
<%= f.text_field :hoge, class:"group-input", id:"group-people-two", placeholder:"例)1" %>人
|
378
|
+
|
379
|
+
</div>
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
<div class="group-text">
|
384
|
+
|
385
|
+
<span>比率</span>
|
386
|
+
|
387
|
+
<span class="indispensable">※</span>
|
388
|
+
|
389
|
+
<%= f.text_field :hoge, class:"group-input", id:"group-ratio-two" ,placeholder:"例)10" %>%
|
390
|
+
|
391
|
+
</div>
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
<div class="group-text">
|
396
|
+
|
397
|
+
<span>一人あたり</span>
|
398
|
+
|
399
|
+
<span class="indispensable">※</span>
|
400
|
+
|
401
|
+
<%= f.text_field :hoge, class:"group-input", id:"group-price-two", placeholder:"例)10000" %>円
|
402
|
+
|
403
|
+
</div>
|
404
|
+
|
405
|
+
</div>
|
406
|
+
|
407
|
+
<%# グループ2 %>
|
408
|
+
|
409
|
+
|
410
|
+
|
411
|
+
<%# グループ3 %>
|
412
|
+
|
413
|
+
<div class="group">
|
414
|
+
|
415
|
+
<div class="group-text">
|
416
|
+
|
417
|
+
<span>グループ名</span>
|
418
|
+
|
419
|
+
<%= f.text_field :hoge, class:"group-input-name", id:"group-name-three", placeholder:"例)グループ3" %>
|
420
|
+
|
421
|
+
</div>
|
422
|
+
|
423
|
+
|
424
|
+
|
425
|
+
<div class="group-text">
|
426
|
+
|
427
|
+
<span>人数</span>
|
428
|
+
|
429
|
+
<span class="indispensable">※</span>
|
430
|
+
|
431
|
+
<%= f.text_field :hoge, class:"group-input", id:"group-people-three", placeholder:"例)1" %>人
|
432
|
+
|
433
|
+
</div>
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
<div class="group-text">
|
438
|
+
|
439
|
+
<span>比率</span>
|
440
|
+
|
441
|
+
<span class="indispensable">※</span>
|
442
|
+
|
443
|
+
<%= f.text_field :hoge, class:"group-input", id:"group-ratio-three", placeholder:"例)10" %>%
|
444
|
+
|
445
|
+
</div>
|
446
|
+
|
447
|
+
|
448
|
+
|
449
|
+
|
450
|
+
|
451
|
+
<div class="group-text">
|
452
|
+
|
453
|
+
<span>一人あたり</span>
|
454
|
+
|
455
|
+
<span class="indispensable">※</span>
|
456
|
+
|
457
|
+
<%= f.text_field :hoge, class:"group-input", id:"group-price-three", placeholder:"例)10000" %>円
|
458
|
+
|
459
|
+
</div>
|
460
|
+
|
461
|
+
</div>
|
462
|
+
|
463
|
+
<%# グループ3 %>
|
464
|
+
|
465
|
+
|
466
|
+
|
467
|
+
<div class="group-invisible">
|
468
|
+
|
469
|
+
<div class="indivisible-number">
|
470
|
+
|
471
|
+
<span>あまり</span>
|
472
|
+
|
473
|
+
<span id='indivisible-number'></span>円
|
474
|
+
|
475
|
+
</div>
|
476
|
+
|
477
|
+
</div>
|
478
|
+
|
479
|
+
<%# /販売価格 %>
|
480
|
+
|
481
|
+
|
482
|
+
|
483
|
+
<% end %>
|
484
|
+
|
485
|
+
</div>
|
202
486
|
|
203
487
|
```
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
```HTML
|
208
|
-
|
209
|
-
<div class="calc-contents">
|
210
|
-
|
211
|
-
<header class="calc-header">
|
212
|
-
|
213
|
-
</header>
|
214
|
-
|
215
|
-
<div class="calc-main">
|
216
|
-
|
217
|
-
<%= form_with local: true do |f| %>
|
218
|
-
|
219
|
-
<div class="calc-title-one">情報を入力</div>
|
220
|
-
|
221
|
-
<div class="total">
|
222
|
-
|
223
|
-
<div class="total-payment">
|
224
|
-
|
225
|
-
<span>総支払額</span>
|
226
|
-
|
227
|
-
<span class="indispensable">※</span>
|
228
|
-
|
229
|
-
<%= f.text_field :hoge, class:"total-people", id:"total-payment", placeholder:"例)50000" %>円
|
230
|
-
|
231
|
-
</div>
|
232
|
-
|
233
|
-
<div class="total-people">
|
234
|
-
|
235
|
-
<span>総人数</span>
|
236
|
-
|
237
|
-
<span class="indispensable">※</span>
|
238
|
-
|
239
|
-
<%= f.text_field :hoge, class:"total-people", id:"total-people", placeholder:"例)5" %>人
|
240
|
-
|
241
|
-
</div>
|
242
|
-
|
243
|
-
</div>
|
244
|
-
|
245
|
-
<div class="calc-title-two">計算を入力</div>
|
246
|
-
|
247
|
-
<div class="calc-description">グループ2以降から数値を入力してください。<span class="indispensable-description">※は必須項目です。</span></div>
|
248
|
-
|
249
|
-
<div class="calc-description">比率か一人当たりの金額どちらか一方を記入すれば、もう一方が自動で表示されます。</div>
|
250
|
-
|
251
|
-
<div class="description_one">グループ1には、総額・総人数からグループ2以降の値を引いた数値が表示されます。</div>
|
252
|
-
|
253
|
-
<div class ="description_two">10の位で切り上げを行うため、あまりが生じます。</div>
|
254
|
-
|
255
|
-
<div class="description_one">比率は小数点二位で切り捨てを行なっています。</div>
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
<%# 販売価格 %>
|
262
|
-
|
263
|
-
<%# グループ1 %>
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
<div class="group">
|
268
|
-
|
269
|
-
<div class="group-text">
|
270
|
-
|
271
|
-
<span class="group-name"> グループ名</span>
|
272
|
-
|
273
|
-
<%= f.text_field :hoge, class:"group-input-name", id:"group-name-one", placeholder:"例)グループ1" %>
|
274
|
-
|
275
|
-
</div>
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
<div class="group">
|
280
|
-
|
281
|
-
<div class="group-text-one">
|
282
|
-
|
283
|
-
<span>人数</span>
|
284
|
-
|
285
|
-
<span id='group-people-one'></span>人
|
286
|
-
|
287
|
-
</div>
|
288
|
-
|
289
|
-
</div>
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
<div class="group">
|
294
|
-
|
295
|
-
<div class="group-text-one">
|
296
|
-
|
297
|
-
<span>比率</span>
|
298
|
-
|
299
|
-
<span id='group-ratio-one'></span>%
|
300
|
-
|
301
|
-
</div>
|
302
|
-
|
303
|
-
</div>
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
<div class="group">
|
308
|
-
|
309
|
-
<div class="group-text-one">
|
310
|
-
|
311
|
-
<span>一人あたり</span>
|
312
|
-
|
313
|
-
<span id='group-price-one'></span>円
|
314
|
-
|
315
|
-
</div>
|
316
|
-
|
317
|
-
</div>
|
318
|
-
|
319
|
-
</div>
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
<%# グループ1 %>
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
<%# グループ2 %>
|
328
|
-
|
329
|
-
<div class="group">
|
330
|
-
|
331
|
-
<div class="group-text">
|
332
|
-
|
333
|
-
<span>グループ名</span>
|
334
|
-
|
335
|
-
<%= f.text_field :hoge, class:"group-input-name", id:"group-name-two", placeholder:"例)グループ2" %>
|
336
|
-
|
337
|
-
</div>
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
<div class="group-text">
|
342
|
-
|
343
|
-
<span>人数</span>
|
344
|
-
|
345
|
-
<span class="indispensable">※</span>
|
346
|
-
|
347
|
-
<%= f.text_field :hoge, class:"group-input", id:"group-people-two", placeholder:"例)1" %>人
|
348
|
-
|
349
|
-
</div>
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
<div class="group-text">
|
354
|
-
|
355
|
-
<span>比率</span>
|
356
|
-
|
357
|
-
<span class="indispensable">※</span>
|
358
|
-
|
359
|
-
<%= f.text_field :hoge, class:"group-input", id:"group-ratio-two" ,placeholder:"例)10" %>%
|
360
|
-
|
361
|
-
</div>
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
<div class="group-text">
|
366
|
-
|
367
|
-
<span>一人あたり</span>
|
368
|
-
|
369
|
-
<span class="indispensable">※</span>
|
370
|
-
|
371
|
-
<%= f.text_field :hoge, class:"group-input", id:"group-price-two", placeholder:"例)10000" %>円
|
372
|
-
|
373
|
-
</div>
|
374
|
-
|
375
|
-
</div>
|
376
|
-
|
377
|
-
<%# グループ2 %>
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
<%# グループ3 %>
|
382
|
-
|
383
|
-
<div class="group">
|
384
|
-
|
385
|
-
<div class="group-text">
|
386
|
-
|
387
|
-
<span>グループ名</span>
|
388
|
-
|
389
|
-
<%= f.text_field :hoge, class:"group-input-name", id:"group-name-three", placeholder:"例)グループ3" %>
|
390
|
-
|
391
|
-
</div>
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
<div class="group-text">
|
396
|
-
|
397
|
-
<span>人数</span>
|
398
|
-
|
399
|
-
<span class="indispensable">※</span>
|
400
|
-
|
401
|
-
<%= f.text_field :hoge, class:"group-input", id:"group-people-three", placeholder:"例)1" %>人
|
402
|
-
|
403
|
-
</div>
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
<div class="group-text">
|
408
|
-
|
409
|
-
<span>比率</span>
|
410
|
-
|
411
|
-
<span class="indispensable">※</span>
|
412
|
-
|
413
|
-
<%= f.text_field :hoge, class:"group-input", id:"group-ratio-three", placeholder:"例)10" %>%
|
414
|
-
|
415
|
-
</div>
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
<div class="group-text">
|
422
|
-
|
423
|
-
<span>一人あたり</span>
|
424
|
-
|
425
|
-
<span class="indispensable">※</span>
|
426
|
-
|
427
|
-
<%= f.text_field :hoge, class:"group-input", id:"group-price-three", placeholder:"例)10000" %>円
|
428
|
-
|
429
|
-
</div>
|
430
|
-
|
431
|
-
</div>
|
432
|
-
|
433
|
-
<%# グループ3 %>
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
<div class="group-invisible">
|
438
|
-
|
439
|
-
<div class="indivisible-number">
|
440
|
-
|
441
|
-
<span>あまり</span>
|
442
|
-
|
443
|
-
<span id='indivisible-number'></span>円
|
444
|
-
|
445
|
-
</div>
|
446
|
-
|
447
|
-
</div>
|
448
|
-
|
449
|
-
<%# /販売価格 %>
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
<% end %>
|
454
|
-
|
455
|
-
</div>
|
456
|
-
|
457
|
-
```
|
2
HTMLの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -206,7 +206,65 @@
|
|
206
206
|
|
207
207
|
```HTML
|
208
208
|
|
209
|
+
<div class="calc-contents">
|
210
|
+
|
211
|
+
<header class="calc-header">
|
212
|
+
|
213
|
+
</header>
|
214
|
+
|
215
|
+
<div class="calc-main">
|
216
|
+
|
217
|
+
<%= form_with local: true do |f| %>
|
218
|
+
|
219
|
+
<div class="calc-title-one">情報を入力</div>
|
220
|
+
|
221
|
+
<div class="total">
|
222
|
+
|
223
|
+
<div class="total-payment">
|
224
|
+
|
225
|
+
<span>総支払額</span>
|
226
|
+
|
227
|
+
<span class="indispensable">※</span>
|
228
|
+
|
229
|
+
<%= f.text_field :hoge, class:"total-people", id:"total-payment", placeholder:"例)50000" %>円
|
230
|
+
|
231
|
+
</div>
|
232
|
+
|
233
|
+
<div class="total-people">
|
234
|
+
|
235
|
+
<span>総人数</span>
|
236
|
+
|
237
|
+
<span class="indispensable">※</span>
|
238
|
+
|
239
|
+
<%= f.text_field :hoge, class:"total-people", id:"total-people", placeholder:"例)5" %>人
|
240
|
+
|
241
|
+
</div>
|
242
|
+
|
243
|
+
</div>
|
244
|
+
|
245
|
+
<div class="calc-title-two">計算を入力</div>
|
246
|
+
|
247
|
+
<div class="calc-description">グループ2以降から数値を入力してください。<span class="indispensable-description">※は必須項目です。</span></div>
|
248
|
+
|
249
|
+
<div class="calc-description">比率か一人当たりの金額どちらか一方を記入すれば、もう一方が自動で表示されます。</div>
|
250
|
+
|
251
|
+
<div class="description_one">グループ1には、総額・総人数からグループ2以降の値を引いた数値が表示されます。</div>
|
252
|
+
|
253
|
+
<div class ="description_two">10の位で切り上げを行うため、あまりが生じます。</div>
|
254
|
+
|
255
|
+
<div class="description_one">比率は小数点二位で切り捨てを行なっています。</div>
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
<%# 販売価格 %>
|
262
|
+
|
263
|
+
<%# グループ1 %>
|
264
|
+
|
265
|
+
|
266
|
+
|
209
|
-
<div class="group">
|
267
|
+
<div class="group">
|
210
268
|
|
211
269
|
<div class="group-text">
|
212
270
|
|
@@ -390,4 +448,10 @@
|
|
390
448
|
|
391
449
|
<%# /販売価格 %>
|
392
450
|
|
451
|
+
|
452
|
+
|
453
|
+
<% end %>
|
454
|
+
|
455
|
+
</div>
|
456
|
+
|
393
457
|
```
|
1
HTMLの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -201,3 +201,193 @@
|
|
201
201
|
});
|
202
202
|
|
203
203
|
```
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
```HTML
|
208
|
+
|
209
|
+
<div class="group">
|
210
|
+
|
211
|
+
<div class="group-text">
|
212
|
+
|
213
|
+
<span class="group-name"> グループ名</span>
|
214
|
+
|
215
|
+
<%= f.text_field :hoge, class:"group-input-name", id:"group-name-one", placeholder:"例)グループ1" %>
|
216
|
+
|
217
|
+
</div>
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
<div class="group">
|
222
|
+
|
223
|
+
<div class="group-text-one">
|
224
|
+
|
225
|
+
<span>人数</span>
|
226
|
+
|
227
|
+
<span id='group-people-one'></span>人
|
228
|
+
|
229
|
+
</div>
|
230
|
+
|
231
|
+
</div>
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
<div class="group">
|
236
|
+
|
237
|
+
<div class="group-text-one">
|
238
|
+
|
239
|
+
<span>比率</span>
|
240
|
+
|
241
|
+
<span id='group-ratio-one'></span>%
|
242
|
+
|
243
|
+
</div>
|
244
|
+
|
245
|
+
</div>
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
<div class="group">
|
250
|
+
|
251
|
+
<div class="group-text-one">
|
252
|
+
|
253
|
+
<span>一人あたり</span>
|
254
|
+
|
255
|
+
<span id='group-price-one'></span>円
|
256
|
+
|
257
|
+
</div>
|
258
|
+
|
259
|
+
</div>
|
260
|
+
|
261
|
+
</div>
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
<%# グループ1 %>
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
<%# グループ2 %>
|
270
|
+
|
271
|
+
<div class="group">
|
272
|
+
|
273
|
+
<div class="group-text">
|
274
|
+
|
275
|
+
<span>グループ名</span>
|
276
|
+
|
277
|
+
<%= f.text_field :hoge, class:"group-input-name", id:"group-name-two", placeholder:"例)グループ2" %>
|
278
|
+
|
279
|
+
</div>
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
<div class="group-text">
|
284
|
+
|
285
|
+
<span>人数</span>
|
286
|
+
|
287
|
+
<span class="indispensable">※</span>
|
288
|
+
|
289
|
+
<%= f.text_field :hoge, class:"group-input", id:"group-people-two", placeholder:"例)1" %>人
|
290
|
+
|
291
|
+
</div>
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
<div class="group-text">
|
296
|
+
|
297
|
+
<span>比率</span>
|
298
|
+
|
299
|
+
<span class="indispensable">※</span>
|
300
|
+
|
301
|
+
<%= f.text_field :hoge, class:"group-input", id:"group-ratio-two" ,placeholder:"例)10" %>%
|
302
|
+
|
303
|
+
</div>
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
<div class="group-text">
|
308
|
+
|
309
|
+
<span>一人あたり</span>
|
310
|
+
|
311
|
+
<span class="indispensable">※</span>
|
312
|
+
|
313
|
+
<%= f.text_field :hoge, class:"group-input", id:"group-price-two", placeholder:"例)10000" %>円
|
314
|
+
|
315
|
+
</div>
|
316
|
+
|
317
|
+
</div>
|
318
|
+
|
319
|
+
<%# グループ2 %>
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
<%# グループ3 %>
|
324
|
+
|
325
|
+
<div class="group">
|
326
|
+
|
327
|
+
<div class="group-text">
|
328
|
+
|
329
|
+
<span>グループ名</span>
|
330
|
+
|
331
|
+
<%= f.text_field :hoge, class:"group-input-name", id:"group-name-three", placeholder:"例)グループ3" %>
|
332
|
+
|
333
|
+
</div>
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
<div class="group-text">
|
338
|
+
|
339
|
+
<span>人数</span>
|
340
|
+
|
341
|
+
<span class="indispensable">※</span>
|
342
|
+
|
343
|
+
<%= f.text_field :hoge, class:"group-input", id:"group-people-three", placeholder:"例)1" %>人
|
344
|
+
|
345
|
+
</div>
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
<div class="group-text">
|
350
|
+
|
351
|
+
<span>比率</span>
|
352
|
+
|
353
|
+
<span class="indispensable">※</span>
|
354
|
+
|
355
|
+
<%= f.text_field :hoge, class:"group-input", id:"group-ratio-three", placeholder:"例)10" %>%
|
356
|
+
|
357
|
+
</div>
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
<div class="group-text">
|
364
|
+
|
365
|
+
<span>一人あたり</span>
|
366
|
+
|
367
|
+
<span class="indispensable">※</span>
|
368
|
+
|
369
|
+
<%= f.text_field :hoge, class:"group-input", id:"group-price-three", placeholder:"例)10000" %>円
|
370
|
+
|
371
|
+
</div>
|
372
|
+
|
373
|
+
</div>
|
374
|
+
|
375
|
+
<%# グループ3 %>
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
<div class="group-invisible">
|
380
|
+
|
381
|
+
<div class="indivisible-number">
|
382
|
+
|
383
|
+
<span>あまり</span>
|
384
|
+
|
385
|
+
<span id='indivisible-number'></span>円
|
386
|
+
|
387
|
+
</div>
|
388
|
+
|
389
|
+
</div>
|
390
|
+
|
391
|
+
<%# /販売価格 %>
|
392
|
+
|
393
|
+
```
|