S
shanshanhao
Unregistered / Unconfirmed
GUEST, unregistred user!
有时候点删除按钮不删哪一行,有时候再第四行点删除,删了第三行,有时候点删除吧提交按钮给删了,下面是代码,请大家帮忙找原因>
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html;
charset=gb2312">
<title>清空</title>
<script language="javascript">
<!--
//删除指定的行
function DeleteOneRow(tableId,rowIndex)
{
var objTable =do
cument.getElementById(tableId);
if(objTable.rows.length==1 || rowIndex==0) {
alert("对不起,你首先必须选择要删除的行!!!"
return;
}
if(confirm("确定删除?") {
objTable.deleteRow(rowIndex);
currRowIndex = 0;
}
else
{
for(var i=1;i<objTable.rows.length;i++){
objTable.rows.cells[0].bgColor = "#ffffff";
currRowIndex = 0;
}
}
}
-->
</script>
</head>
<body>
<table id=table1 border="1"
cellpadding="0"
cellspacing="0"
align =center width="697"
>
<form action="sample.asp"
method="post"
name="form1"width="60%">
<tr><td height="18"
> 姓名</td>
<td height="18"
> 数据</td>
<td height="18"
> 日期</td></tr>
<%for i=1 to 5%>
<tr>
<td><%=i%> <input type="text"
name="username<%=i%>"
value="<%=username%>"></td>
<td> <input type="text"
name="userdata<%=i%>"
value="<%=userdata%>"></td>
<td> <input type="text"
name="sdate<%=i%>"
value="<%=sdate%>"></td>
<td align="center"
><input type="button"
value="
删除 "
onclick="DeleteOneRow('table1', <%=i%>)"></tr>
<tr>
<%next%>
<td><input type="submit"
value="提交数据"></td>
</tr>
</form>
</table>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html;
charset=gb2312">
<title>清空</title>
<script language="javascript">
<!--
//删除指定的行
function DeleteOneRow(tableId,rowIndex)
{
var objTable =do
cument.getElementById(tableId);
if(objTable.rows.length==1 || rowIndex==0) {
alert("对不起,你首先必须选择要删除的行!!!"
return;
}
if(confirm("确定删除?") {
objTable.deleteRow(rowIndex);
currRowIndex = 0;
}
else
{
for(var i=1;i<objTable.rows.length;i++){
objTable.rows.cells[0].bgColor = "#ffffff";
currRowIndex = 0;
}
}
}
-->
</script>
</head>
<body>
<table id=table1 border="1"
cellpadding="0"
cellspacing="0"
align =center width="697"
>
<form action="sample.asp"
method="post"
name="form1"width="60%">
<tr><td height="18"
> 姓名</td>
<td height="18"
> 数据</td>
<td height="18"
> 日期</td></tr>
<%for i=1 to 5%>
<tr>
<td><%=i%> <input type="text"
name="username<%=i%>"
value="<%=username%>"></td>
<td> <input type="text"
name="userdata<%=i%>"
value="<%=userdata%>"></td>
<td> <input type="text"
name="sdate<%=i%>"
value="<%=sdate%>"></td>
<td align="center"
><input type="button"
value="
删除 "
onclick="DeleteOneRow('table1', <%=i%>)"></tr>
<tr>
<%next%>
<td><input type="submit"
value="提交数据"></td>
</tr>
</form>
</table>
</body>
</html>