<html>
<head>
<title>tree</title>
<meta name="designer" content="csdn design team - meizz" />
<script>
function delRow()
{
mytable2.deleteRow(0);
}
</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" id="mytable2">
<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>
<head>
<title>tree</title>
<meta name="designer" content="csdn design team - meizz" />
<script>
function delRow()
{
mytable2.deleteRow(0);
}
</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" id="mytable2">
<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>
解决方案 »
- html传参数给javascript的问题
- 动态添加的blur事件失效
- 求个方法选择图片后自动提交表单
- IE7下使用AlphaImageLoader可以上传预览图片,那读取文件size要怎么实现呢?
- 15位身份证后面日期和顺序号的正则表达式是怎样的?
- <script src="/mint/?js" ...............
- 如何知道某个表格中有多少行?即有多少tr
- 菜鸟问题:如何实现弹出对话框“确认”“取消”,在线等待
- 如何在Javascript中取jsp中数组里的值
- js读取excel文件时,workbooks.open(filePath)出错,只在xp,ie8上无法执行,其他电脑正常
- 怎么样取得一组checkbox的个数?
- 高分求JS的API
<head>
<title>tree</title>
<meta name="designer" content="csdn design team - meizz" />
<script>
function delRow(){
var subtables=mytable.rows[0].cells[0].childNodes;
// td tr tbody table
event.srcElement.parentNode.parentNode.parentNode.parentNode.removeNode()
//不知道你这个循环是什么意思,大概是填充编号吧,不知道我理解的对不对
for (var i =0; i<subtables.length;i++){
if(subtables[i].rows[0].cells[1])
subtables[i].rows[0].cells[1].childNodes[0].value=i;
}
}
</script>
</head>
<body>
要显示的内容:
<form name="form1" 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>
//表中要删除的行号
function delRow(tableID, rowsIndex)
{
var objTable = document.getElementById(tableID);
if(rowsIndex < objTable.rows.length){
objTable.deleteRow(rowsIndex);
}else{
alert('Row is not exist!');
}
}
function delRow(){
var delRow=document.all("mytable1").deleteRow(event.srcElement.rowIndex);
}
因为我的表格是可以上下托动的,如果用我的这个,我托动一次,再点删除,就全删掉了,用你的,托动没有问题,删除的时候,有些在线编辑器的东西删除不掉,所以怀疑是不是这句:
event.srcElement.parentNode.parentNode.parentNode.parentNode.removeNode()
在搞怪.