<script language= "JavaScript" >
function Checkall (form)
{///defines function Checkall, parameter is form
for (var i=0;i<form.elements.length;i++)
///loops, Form.elements.length gets the number of controls in the form
{
///the contents of the form to the variable
var e = form.elements[i];
if (e.name!= ' Chkall ')
e.checked = form.chkall.checked;
}
}
</script>
<form id= "Form1" Name= "Form1" method= "Post" action= "" >
<table width= cellspacing= "1" cellpadding= "0" >
<tr>
<td width= > All </td>
<TD width= "169" ><input name= "Chkall" type= "checkbox" id= "Chkall" value= "All" onclick= "Checkall" (this.form) "/ ></td>
</tr>
<tr>
<td><input name= "id" type= "checkbox" id= "id" value= "1"/></td>
<td>1 title 1</td>
</tr>
<tr>
<td><input name= "id" type= "checkbox" id= "id" value= "2"/></td>
<td>2 title 2</td>
</tr>
<tr>
<td><input name= "id" type= "checkbox" id= "id" value= "3"/></td>
<td> 3 title 3</td>
</tr>
<tr>
<td><input name= "id" type= "checkbox" id= "id" value= "4"/></td>
<td>4 title 4</td>
</tr>
<tr>
<td><input name= "id" type= "checkbox" id= "id" value= "5"/></td>
<td>5 title 5</td>
</tr>
<tr>
<td><input name= "id" type= "checkbox" id= "id" value= "6"/></td>
<td>6 title 6</td>
</tr>
<tr>
<td><input name= "id" type= "checkbox" id= "id" value= "7"/></td>
<td>7 title 7</td>
</tr>
<tr>
<td><input name= "id" type= "checkbox" id= "id" value= "8"/></td>
<td>8 title 8</td>
</tr>
<tr>
<td><input name= "id" type= "checkbox" id= "id" value= "9"/></td>
<td>9 title 9</td>
</tr>
<tr>
<td> </td>
<td><input type= "Submit" name= "submit" value= "Delete"/></td>
</tr>
</table>
</form>
If you want to pass a value to another file
delete.asp File:
<!--#include file= "inc/conn.asp"-->
<%
num=request.form ("CheckBox1"). Count
if Num=0 then
Response.Write ("Please select News to delete")
Response.End
End If
Ids=request. Form ("CheckBox1")
sqlstr= "Delete * from Indexad Where id" ("&ids&")
Conn.execute (SQLSTR)
Response.Redirect (Request.ServerVariables ("Http_referer"))
Response.End
%>
Method 2
<%
num=request.form ("Delid"). Count
if Num=0 then
Response.Write ("Please select News to delete")
Response.End
End If
for I=1 to Num
set Rs=server.createobject ("ADODB. Recordset ")
Sql= "Select * from News where newsid=" &request.form ("Delid") (i)
Rs.Open sql,conn,1,1
if not rs.eof then
Conn.execute ("Delete from News Where newsid=" &request.form ("Delid") (i))
Conn.execute ("Delete from Review Where newsid=" &request.form ("Delid") (i))
Else
Response.Write ("News deletion failed")
Response.End
End If
Rs.close
Set rs=nothing
Next
Response.Write ("Delete selected news successfully")
Response.End
%>