質問するログイン新規登録

回答編集履歴

1

chousei

2019/05/27 04:44

投稿

yambejp
yambejp

スコア118102

answer CHANGED
@@ -7,11 +7,12 @@
7
7
  mikan:parseInt(document.querySelector('[name=mikan]').dataset["tanka"]),
8
8
  };
9
9
  var num=[].map.call(document.querySelectorAll('#t1 thead th'),function(x){
10
- return parseInt(x.textContent);
10
+ return parseInt(x.textContent)||"";
11
11
  });
12
12
  [].forEach.call(document.querySelectorAll('[data-tanka]'),function(x){
13
13
  x.addEventListener("input",function(){
14
14
  [].forEach.call(document.querySelectorAll('#t1 tbody td'),function(x,y){
15
+ if(num[y]=="") return;
15
16
  var v=0
16
17
  +tanka["ringo"]*parseInt(document.querySelector('[name=ringo]').value)
17
18
  +tanka["mikan"]*parseInt(document.querySelector('[name=mikan]').value);
@@ -27,6 +28,7 @@
27
28
  <table id="t1" border>
28
29
  <thead>
29
30
  <tr>
31
+ <th>&nbsp;</th>
30
32
  <th>10</th>
31
33
  <th>20</th>
32
34
  <th>30</th>
@@ -41,6 +43,7 @@
41
43
  </thead>
42
44
  <tbody>
43
45
  <tr>
46
+ <td>合計金額</td>
44
47
  <td>0</td>
45
48
  <td>0</td>
46
49
  <td>0</td>