回答編集履歴
2
修正
test
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
var num=Array.prototype.map.call(document.querySelectorAll('[name="k-subtotal"]'),function(x){
|
12
12
|
|
13
|
-
return parseInt(x.value);
|
13
|
+
return parseInt(x.value)||0; /*一部エラー回避処理を追記*/
|
14
14
|
|
15
15
|
}).reduce(function(x,y) {
|
16
16
|
|
1
調整
test
CHANGED
@@ -4,9 +4,11 @@
|
|
4
4
|
|
5
5
|
```javascript
|
6
6
|
|
7
|
+
<script>
|
8
|
+
|
7
9
|
window.addEventListener('DOMContentLoaded', function(e){
|
8
10
|
|
9
|
-
var num=Array.prototype.map.call(document.querySelectorAll(
|
11
|
+
var num=Array.prototype.map.call(document.querySelectorAll('[name="k-subtotal"]'),function(x){
|
10
12
|
|
11
13
|
return parseInt(x.value);
|
12
14
|
|
@@ -20,9 +22,7 @@
|
|
20
22
|
|
21
23
|
});
|
22
24
|
|
23
|
-
```
|
24
|
-
|
25
|
-
|
25
|
+
</script>
|
26
26
|
|
27
27
|
<input type="text" name="k-subtotal" value="100">
|
28
28
|
|
@@ -33,3 +33,7 @@
|
|
33
33
|
|
34
34
|
|
35
35
|
```
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
※わかりやすくするためソースを結合
|