本人是个菜鸟,想要给留言本弄个批量删除,但是代码改好后删除后记录还在,请各位高手帮帮忙,本人感激不尽!
<!-- 全选 -->
<script language="javascript">
function CheckAll(thisform){
for (var i=0;i<thisform.elements.length;i++){
var e = thisform.elements[i];
if (e.Name != "chkAll"&&e.disabled!=true)
e.checked = thisform.chkAll.checked;
}
}
function unselectall(thisform){
if(thisform.chkAll.checked){
thisform.chkAll.checked = thisform.chkAll.checked&0;
}
}
</script>
<!-- 选择框 -->
<input type="checkbox" value="<%=rs("id")%>" name="id" onClick="unselectall(this.form)" />
<!-- 全选框与删除按钮 -->
<input name="chkAll" type="checkbox" id="chkAll" onClick=CheckAll(this.form) value="checkbox" />
<input name="delete" type="button" class="button" onclick="javascript:if(confirm('确定要删除吗?删除后不可恢复!')){window.location.href='guestbook.asp?action=del_all&id=<%=rs("id")%>';}else{history.go(0);}" value="删除所选" />
<%
'批量删除代码
if request("action")="del_all" then
set rs=server.createobject("adodb.recordset")
id=Replace(Request.Form("id"),", ",",")
chkAll = Split(id,",")
For i = 0 To UBound(chkAll)
sql="select * from guestbook where id in("&chkAll(i)&")"
rs.open sql,conn,2,3
rs.delete
rs.update
Next
Response.Write "<script>alert('刪除成功!');window.location.href='guestbook.asp';</script>"
end if
%>