asp 全选/删除代码问题,请求解决!
我希望对数据库读取的记录做批量操作:全选/删除,现在能够全选,但是不能删除,请求帮助!现附完整代码:index.asp,user_delall.asp,conn.asp,由于里面的修改、单记录删除、添加均正常,所以不附代码,数据库表分:id,name1,sex,old四个字段,表名:mysf_userindex.asp代码
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>用户管理</title>
<link rel="stylesheet" type="text/css">
<!--全选函数-->
<script language=javascript>
var t=false;
function SelectAll()
{
t=!t;
for(var i=0;i<document.form1.elements.length;i++)
{
if (document.form1.elements[i].type=="checkbox")
{
document.form1.elements[i].checked=t;
}
}
}
</script>
</head>
<body leftmargin="8" topmargin="8">
<%
set rs=server.CreateObject("ADODB.RecordSet")
Source="select * from mysf_user order by id"
rs.Open Source,conn,1,1
%>
<table width="98%" border="0" cellpadding="2" cellspacing="1" bgcolor="#D1DDAA"
align="center" style="margin-top:8px">
<tr bgcolor="#E7E7E7">
<td height="24" colspan="10"> 用户列表 </td>
</tr>
<tr align="center" bgcolor="#FAFAF1" height="22">
<td width="6%">ID</td>
<td width="4%">选择</td>
<td width="28%">姓名</td>
<td width="10%">性别</td>
<td width="10%">年龄</td>
<td width="10%">操作</td>
</tr>
<%
if rs.eof and rs.bof then
response.Write("暂时没有数据")
else
Do Until rs.Eof
%>
<!--读取记录-->
<form name="form1" id="form1" action="user_addsave.asp">
<tr align='center' bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='#FCFDEE';"
onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22" >
<td><%=rs("id")%></td>
<td><input name="ids" type="checkbox" id="ids" value="101" class="np" value="<%=rs
("id")%>">
</td>
<td><%=rs("name1")%></td>
<td><%=rs("sex")%></td>
<td><%=rs("old")%></td>
<td><a href="user_edit.asp?id=<%=rs("id")%>">修改</a> | <a href="user_del.asp?
id=<%=rs("id")%>">删除</a></td>
</tr>
<%
rs.MoveNext
Loop
end if
%>
<tr align='center' height="22" >
<td></td>
<td></td>
<td><input name="name1" type="text" id="name1"></td>
<td><input name="sex" type="text" id="sex"></td>
<td><input name="old" type="text" id="old"></td>
<td><input type="submit" value="保存"></td>
</tr>
</form>
<!--全选删除按钮-->
<form method="post" action="user_delall.asp" name="form2" id="form2">
<tr bgcolor="#FAFAF1">
<td height="28" colspan="10">
<input type="button" name="chek" value="全选" id="chek" onClick="SelectAll()">
<input type="submit" name="del" id="del" value="删除">
</td>
</tr>
</form>
</table>
<%
rs.close
set rs=nothing
%>
</body>
</html>
user_delall.asp代码
<!--#include file="conn.asp"-->
<%
set rs=server.CreateObject("ADODB.RecordSet")
Source="select * from mysf_user where id in("&id&")"
rs.Open Source,conn,1,3
rs.delete
response.write "<script>alert('用户删除成功!');window.location.href='index.asp';</script>"
%>
conn.asp代码
<%
set conn=server.createobject("ADODB.CONNECTION")
connstr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath("cs123.mdb")
conn.open connstr
%>
[ 本帖最后由 jm117 于 2012-5-5 14:01 编辑 ]