这是偶刚做的,拿来给你看看可以否:
delete.asp:
<%
i=1
do while not rs_all.EOF and i<=rs_all.PageSize
theId = rs_all("Id")%>
<tr height="33">
<td width="50" align="center">
<input type="checkbox" class =check name="ch" id="<%=theId%>" value="<%=theId%>">
</td>
</tr>
<%
i = i + 1
rs_all.MoveNext
loop
%>
接受页面:
theCount = Request.Form("ch").Count
Redim check(theCount)
for i=1 to theCount
theCheck = Request.Form("ch")(i)
check(i-1) = theCheck '把需要删除的全部发在数组里面
next
value = ""
for i = lbound(check) to ubound(check)
value = value&","&check(i) '把数组里面的值与逗号组合成一个字符串
next
value =left(value,len(value)-1) '去掉字符串右边的逗号
if instr(1,value,",",1) = 0 then
Response.Write "选择错误,没有记录可以删除"
Response.End
end if
value =right(value,len(value)-1) '去掉字符串左边的逗号,得出如:2,3,5,6 似的字符串
sql_dele = "delete from product where Id in ("&value&")"
conn.execute(sql_dele) '执行删除任务
conn.close
set conn = nothing