我需要的

function showInfo(haha){

var  cprice=0;
var xx=0;
var table=document.getElementById("detailTable");
var trs=haha.parentNode.parentNode;
var rowindex=trs.rowIndex;
var danjia=table.rows[rowindex].cells[2].firstChild.value;
danjia=parseInt(danjia);
var shuliang=table.rows[rowindex].cells[3].firstChild.value;
shuliang=parseInt(shuliang);
table.rows[rowindex].cells[5].firstChild.value=danjia*shuliang;
document.getElementById("changpingzongjia").value=danjia*shuliang;
var fujia=document.getElementById("fujia").value;

document.getElementById("zongjia").value=parseInt(fujia)+parseInt(danjia*shuliang);
}


<html>


<head>
<script language="javascript" type="text/javascript">

function addItem() {
var detailTable = document.getElementById("detailTable");
var oRow = detailTable.insertRow(-1);//在表格最后添加一行

oRow.align = "center";
    oRow.className ="toolbar";
   
oCell = oRow.insertCell(0);//添加单元格
oCell.innerHTML = oRow.rowIndex;

oCell = oRow.insertCell(1);
oCell.innerHTML = "<input type='text'  name='spbm' size='10' readonly> <span class='LL'><image src='../C:/Documents and Settings/user/桌面/delete.gif' onClick='choiceSpxx(\""+(oRow.rowIndex-1)+"\")'></span>";
   
    // oCell.class= ;
    
oCell = oRow.insertCell(2);
oCell.innerHTML = "<input type='text' name='spmc' size='15' readonly>";

oCell = oRow.insertCell(3);
oCell.innerHTML = "<input type='text' name='ytsl' size='10' value='0'>";

oCell = oRow.insertCell(4);
oCell.innerHTML = "<input type='text' name='sptj' size='10' value='0' >";

oCell = oRow.insertCell(5);
oCell.innerHTML = "<input type='text' name='spzl' size='10' value='0' >";

oCell = oRow.insertCell(6);
oCell.innerHTML = "<input type='text' name='stsl' size='10' value='0'>";

oCell = oRow.insertCell(7);
oCell.innerHTML = "<input type='text' name='spbz' size='15'>";

oCell = oRow.insertCell(8);
oCell.innerHTML = '<image src="../C:/Documents and Settings/user/桌面/delete.gif" class="LL" onclick="delItem('+oRow.rowIndex+')"/>';
}
//删除行,注意这里的行号全部要重新计算 刷新的
function delItem(index) {
var detailTable = document.getElementById("detailTable");
alert(index);


detailTable.deleteRow(index);
var rowNum = detailTable.rows.length;
var rowlength = detailTable.rows[0].cells.length;
for (i=index; i<rowNum; i++) {
detailTable.rows[i].cells[0].innerHTML = i;
detailTable.rows[i].cells[rowlength-1].innerHTML = '<image src="../images/delete.gif" class="LL" onclick="delItem('+i+')"/>';
}
}
</script>


</head>

<body>

<table width="100%"  border="1" align="center" cellspacing="1" id="detailTable">
  <tr>
    <td class="toolbar"> 序号 </td>
    <td class="toolbar"> 商品编码 </td>
    <td class="toolbar"> 商品名称 </td>

    <td class="toolbar"> 应提数量 </td>
    <td class="toolbar"> 商品体积 </td>
    <td class="toolbar">商品重量</td>
    <td class="toolbar">实提数量</td>
    <td class="toolbar">备注</td>

    <td class="toolbar">&nbsp;</td>
  </tr>
</table>

<input type="button" value="zengjia" onclick="addItem()"/>


</body>
</html>

你可能感兴趣的:(我需要的)