Method One:
Copy Code code as follows:
Id=request.form ("checkbox")
Id=split (ID, ",")
Shu=0
For i=0 to UBound (ID)
Sql= "SELECT * from Jiang_fname where id=" &id (i)
Set Rs=conn.execute (SQL)
If not rs.eof then
Delete_file (RS ("fname"))
End If
Rs.close
Set rs=nothing
Sql= "Delete from Jiang_fname where id=" &id (i)
Conn.execute SQL,SHU1
Shu=shu+1
Next
If Shu>0 Then
Response. Write ("<script>alert (' delete success '); location.href= '" &url& "';</script>")
Else
Response.Write (' <script>alert (' delete failed '); Javascript:history.back ();</script> ")
End If
Conn.close
Set conn=nothing
Method Two: Use in the keyword to realize the batch deletion of the data skillfully
Managenews.asp
Copy Code code as follows:
<!--#include file= "conn.asp"-->
<% ' Database connection file I'm not going to say much more.%> <title> Management News </title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<link rel= "stylesheet" href= ". /index/style.css "type=" Text/css ">
<script>
Function del ()//used to determine whether a record has been selected
{
var flag=true;
var temp= "";
var tmp;
if ((document.form1.answer.length+ "") = = "undefined") {tmp=1}else{tmp=document.form1.answer.length}
if (tmp==1) {
if (document.form1.answer.checked) {
Flag=false;
Temp=document.form1.answer.value
}
}else{
for (i=0;i<document.form1.answer.length;i++) {
if (document.form1.answer[i].checked) {
if (temp== "") {
Flag=false;
Temp=document.form1.answer[i].value
}else{
Flag=false;
Temp = temp + "," + document.form1.answer[i].value
}
}
}
}
if (flag) {alert ("Sorry, you have no choice!") ")}
else{Name=document.form1.name.value
Alert (name)
if (confirm) (Are you sure you want to delete?) ")){
Window.location= "delnews.asp?id=" + temp;
}
}
return!flag;
}
</script>
<body>
<script language=javascript>
function Checkall (all)//functions for judging all selected records
{
var a = Document.getelementsbyname ("answer");
for (var i=0; i<a.length; i++) a[i].checked = all.checked;
}
</script>
<%
Set Rs=server.createobject ("Adodb.recordset")
Sql= "SELECT * FROM News ORDER BY addtime Desc"
Rs.Open sql,conn,1,3%>
<% if Rs.eof then%>
<table width= "50%" border= "0" align= "center" id= "Table2" >
<tr>
<TD align= "center" >
No news!
</tr>
</table>
<% Else%>
<form method= "POST" Id=form1 name=form1>
<table width= "90%" border= "0" align= "center" class= "Tabdocborder" id= "Table3" >
<tr>
<td>
<table width= "80%" align= "center" id=tabdocmain border= ' 1 ' cellspacing= ' 0 ' cellpadding= ' 0 ' bordercolorlight= ' 82B4DD ' bordercolor= ' #b6d3eb ' class= "Tabdocmain" >
<thead>
<tr>
<TD colspan= "7" align= "Center" >
News Management Center
</td>
</tr>
</thead>
<tbody>
<tr>
<TD align=center>
Delete Box
</td>
<TD align=center>
News Headlines
</td>
<TD align=center>
Publish Time
</td>
<TD align=center>
Management
</td>
</tr>
<%
Do as not rs.eof
%>
<tr>
<TD align=center><input type= "checkbox" name= "Answer" value= "<%=rs" ("id")%> "id=" Checkbox1 ">
</td>
<TD align=left><%if Len (rs ("title")) <=30 Then%><%=rs ("title")%><%else%>
<%= (Left (RS ("title"),)%> ....
<%end if%></td>
<TD align=left><%=rs ("Addtime")%></td>
<TD align=center><a href= "editnews.asp?id=<%=rs (" id ")%>" > Edit </a></td>
</tr>
</tbody>
<%
Rs.movenext
Loop
%>
<tr>
<TD colspan= "7" align= "Center" >
<input type= "checkbox" Name= "Chkall" value= "on" onclick= "Checkall (This)" id= "Checkbox2" > select all Display News
<input type= "button" Name= "Btndelete" value= "delete" Style= ' font-family: Song body; Font-size:9pt ' onclick= ' del () "id=" Button1 ">
</td>
</tr>
</table>
</form>
</td>
</tr>
<%end if%>
</table>
<% Set rs=nothing
Conn.close
Set conn=nothing
%>
</body>
delnews.asp file
Copy Code code as follows:
<!--#include file= "conn.asp"-->
<%
arrdel=request ("id")
' Response.Write arrdel
sql= ' DELETE from news where ID in (' &arrdel& ') '
' Response.Write SQL
conn. Execute SQL
Set conn=nothing
Response.Write "<script language=javascript>alert (' Delete succeeded! ');"
Response.Write "Javascript:history.go ( -1) </SCRIPT>"
Response.End
%>