小编Sum*_*Das的帖子

以html形式在表格中动态计算行和列操作

账单表格

我正在尝试制作一个账单表格,我需要在输入价格和数量列的值后自动显示生成的金额。但是使用以下代码,我只能计算一行。我希望每次输入值时它都能为每一行工作,最后,它也应该显示金额列的总和。

function deleteRow(row)
{
  var i=row.parentNode.parentNode.rowIndex;
  document.getElementById('billingSheet').deleteRow(i);
}

function addRow(){

  var x=document.getElementById('billingSheet');
     // deep clone the targeted row
  var new_row = x.rows[1].cloneNode(true);
     // get the total number of rows
  var len = x.rows.length;
     // set the innerHTML of the first row 
  new_row.cells[0].innerHTML = len;

  // grab the input from the first cell and update its ID and value
  var inp1 = new_row.cells[1].getElementsByTagName('input')[0];
  inp1.id += len;
  inp1.value = '';

     // grab the input from the second cell and update its …
Run Code Online (Sandbox Code Playgroud)

html javascript css jquery

0
推荐指数
1
解决办法
76
查看次数

标签 统计

css ×1

html ×1

javascript ×1

jquery ×1