例子1:(具体参照drp中的flow_card_add.jsp)
<script>
var rowIndex = 0;
function addOneLineOnClick() {
var row=tblFlowCardDetail.insertRow(tblFlowCardDetail.rows.length);
var col = row.insertCell(0);
col.innerHTML = "<input type=\"hidden\" name=\"aimInnerId\" id=\"aimInnerId\"><input type=button value =... name=btnSelectAimClient index=\""+ rowIndex +"\" >";
col = row.insertCell(1);
col.innerHTML = "<input id=aimName name=aimName size=25 maxlength=25 readonly=\"true\">";
col = row.insertCell(2);
col.innerHTML = "<input type='button' value='删除' id=btnDeleteLine name=btnDeleteLine onclick=\"return DeleteRow('row" + rowIndex + "')\">";
row.setAttribute("id", "row" + rowIndex);
rowIndex++;
}
function DeleteRow(rowTag){
var i = tblFlowCardDetail.rows(rowTag).rowIndex;
var j;
for(j=i;j<=rowIndex;j++) {
tblFlowCardDetail.rows(j).cells(0).all("btnSelectAimClient").index--;
tblFlowCardDetail.rows(j).cells(2).all("btnSelectItem").index--;
}
tblFlowCardDetail.deleteRow(i);
rowIndex--;
}
</script>
<body>
<table>
<tr>
<td>cell0</td>
<td>cell1</td>
<td>cell2</td>
</tr>
</table>
<input name="btnAddLine" type="button" ;
button.onclick = function()
{
parent.removeChild(br);
parent.removeChild(input);
parent.removeChild(button);
};
parent.appendChild(br);
parent.appendChild(input);
parent.appendChild(button);
}
</script>
</body>
转载:http://blog.csdn.net/sprita1/article/details/7536023