永发信息网

asp无法批量删除

答案:1  悬赏:70  手机版
解决时间 2021-08-12 18:11
  • 提问者网友:容嬷嬷拿针来
  • 2021-08-11 22:34

本人是个菜鸟,想要给留言本弄个批量删除,但是代码改好后删除后记录还在,请各位高手帮帮忙,本人感激不尽!

<!-- 全选 -->
<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&amp;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
%>

最佳答案
  • 五星知识达人网友:归鹤鸣
  • 2021-08-11 23:12

<form name="form" method="post" action="">
<!-- 选择框 -->


<input type="checkbox" value="<%=rs("id")%>" name="id" onClick="unselectall(this.form)" />


<!-- 全选框与删除按钮 -->


<input type="checkbox" name="checkbox" value="Check All" onClick="mm()">
<input type="submit" name="Submit class="go-wenbenkuang"" value="删 除" onClick="return test();">
</form>
<script>
function test()
{
if(!confirm('确认删除吗?')) return false;
}
</script>
<script language=javascript>
function mm()
{
var a = document.getElementsByTagName("input");
if(a[0].checked==true){
for (var i=0; i<a.length; i++)
if (a[i].type == "checkbox") a[i].checked = false;
}
else
{
for (var i=0; i<a.length; i++)
if (a[i].type == "checkbox") a[i].checked = true;
}
}
</script>


<%
selectnameid=request("selectnameid")
if selectnameid<>"" then
conn_hotel.execute "delete from guestbook where id in ("&selectnameid&")"


Response.Write "<script>alert('刪除成功!');window.location.href='guestbook.asp';</script>"
response.Redirect "manage_hotel.asp"
response.End
end if
%>



通过看你的代码,利用我之前一个批量删除代码给你改了下。试试能不能帮到你解决问题。如果不能,加我qq:437960263,帮你解决。

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯