質問編集履歴
1
HTMLに表示例を追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -38,7 +38,39 @@
|
|
38
38
|
|
39
39
|
#{/paginate.list}
|
40
40
|
|
41
|
+
|
42
|
+
|
43
|
+
${i.id}=DBの参照しているTableのidごとに表示させています。
|
44
|
+
|
45
|
+
table例
|
46
|
+
|
47
|
+
ID trigerPoint businessPoint replacePoint sumPoint
|
48
|
+
|
49
|
+
1 10 10 10 30
|
50
|
+
|
51
|
+
2 1 1 1 3
|
52
|
+
|
53
|
+
HTML表示例
|
54
|
+
|
55
|
+
trigerPoint businessPoint replacePoint sumPoint
|
56
|
+
|
57
|
+
10 10 10 30
|
58
|
+
|
59
|
+
1 1 1 3
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
問題として現状はSumPointの一番最初にすべて足されています
|
64
|
+
|
65
|
+
|
66
|
+
|
41
67
|
```
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
42
74
|
|
43
75
|
```JavaScript
|
44
76
|
|
@@ -46,51 +78,25 @@
|
|
46
78
|
|
47
79
|
#{set 'moreScripts'}
|
48
80
|
|
81
|
+
<script>
|
49
82
|
|
83
|
+
document.addEventListener('change',function(e){
|
50
84
|
|
51
|
-
|
85
|
+
var t=e.target;
|
52
86
|
|
53
|
-
|
87
|
+
if(t.nodeName=="INPUT" && t.type=="number"){
|
54
88
|
|
55
|
-
|
89
|
+
var sum=0;
|
56
90
|
|
57
|
-
|
91
|
+
Array.prototype.map.call(document.querySelectorAll('input[type=number]'),function(i){;
|
58
92
|
|
59
|
-
el
|
93
|
+
sum+=(parseFloat(i.value)||0);
|
60
94
|
|
61
|
-
|
95
|
+
});
|
62
96
|
|
63
|
-
|
97
|
+
document.querySelector('#ans').innerHTML=sum;
|
64
98
|
|
65
|
-
},
|
66
|
-
|
67
|
-
methods: {
|
68
|
-
|
69
|
-
calc: $('input[type="number"]').change(function() {
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
_trigerPoint = numeral().unformat(this.trigerPoint);
|
74
|
-
|
75
|
-
_businessPoint = numeral().unformat(this.businessPoint);
|
76
|
-
|
77
|
-
_replacePoint = numeral().unformat(this.replacePoint);
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
_total = _trigerPoint + _businessPoint + _replacePoint;
|
82
|
-
|
83
|
-
this.total = _total;
|
84
|
-
|
85
|
-
var val = numeral().unformat(this.total);
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
$('p').text(val);
|
90
|
-
|
91
|
-
|
99
|
+
}
|
92
|
-
|
93
|
-
}
|
94
100
|
|
95
101
|
});
|
96
102
|
|