表格删除问题,各位大虾帮忙,谢谢
存成html文件,就知道我想要说的了,谢谢了,现在删除有点问题,点某一个就全删了。
<html>
<head>
<title>tree</title>
<meta name="designer" content="csdn design team - meizz" />
<script>
function delRow()
{
var rowIndex = event.srcElement.parentNode.parentNode.rowIndex;
event.srcElement.parentNode.parentNode.removeNode(true);
for (var i = rowIndex; i < mytable.rows.length; i++)
{
mytable.rows(i).cells(0).innerHTML = i;
}
}
</script>
</head>
<body>
要显示的内容:
<form name="frm1" method="post" action="/addcontent.jsp">
<table id="mytable" border="1" width="100%">
<tr>
<td width="100%" valign="top" >
<table border="1" width="100%" class="dragTable">
<tr >
<td width="15%" align="right" bgcolor="#cccccc">标题:</td>
<td width="77%" bgcolor="#cccccc">
<input type="text" name="title_3" style="width:100" value="小儿子">
</td>
<td rowspan="2" width="8%" >
<input id="Button_3" type="button" value="删除ID为3的行" onclick="delRow()"/>
</td>
</tr>
<tr >
<td width="15%" align="right" bgcolor="#cccccc">内容:</td>
<td width="77%" >动态给表格增加/删除一行
</td>
</tr>
</table>
<table border="1" width="100%">
<tr >
<td width="15%" align="right" bgcolor="#cccccc">标题:</td>
<td width="77%" bgcolor="#cccccc">
<input type="text" name="title_7" style="width:100" value="二儿子">
</td>
<td rowspan="2" width="8%" >
<input id="Button_7" type="button" value="删除ID为7的行" onclick="delRow()" />
</td>
</tr>
<tr >
<td width="15%" align="right" bgcolor="#cccccc">内容:</td>
<td width="77%" >动态给表格增加/删除一行
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>