<! -- # Include file = "conn. asp" -->
<%
If request. querystring ("action") = "Del" then
'Response. Write (Request ("selectdel "))
Conn.exe cute "delete from shopxp_news where newsid in (" & request ("selectdel ")&")"
Response. Redirect "This. asp"
End if %>
<HTML>
<Head>
<Title> untitled document </title>
<%
'---------------- The paging link function starts --------------------
Function showpage (totalnumber, maxperpage, filename)
Dim N
If totalnumber mod maxperpage = 0 then
N = totalnumber \ maxperpage
Else
N = totalnumber \ maxperpage + 1
End if
Response. Write "<form method = post action =" & filename & ">"
Response. Write "<p align = 'center' class = 'contents'>"
If currentpage <2 then
Response. Write "<font class = 'contents'> Home page </font>"
Else
Response. Write "<a href =" & filename &"? Page = 1 class = 'contents'> homepage </a>"
Response. Write "<a href =" & filename &"? Page = "& CurrentPage-1 &" class = 'contents'> previous </a>"
End if
If n-currentpage <1 then
Response. Write "<font class = 'contents'> next last page </font>"
Else
Response. Write "<a href =" & filename &"? Page = "& (currentpage + 1) &" class = 'contents'>"
Response. Write "next page </a> <a href =" & filename &"? Page = "& N &" class = 'contents'> last page </a>"
End if
Response. Write
"<Font class = 'contents'> page: </font> <font
Class = 'contents'> "& currentpage &" </font> <font
Class = 'contents'>/"& N &" page </font>"
Response. Write "<font class = 'contents'> total" & totalnumber & "items"
Response. Write
"<Font class = 'contents'> to: </font> <input type = 'text'
Name = 'page' size = 2 maxlength = 10 class = "smallinput"
Value = "& currentpage &">"
Response. Write "& nbsp; <input type = 'submit 'class = 'contents' value = 'go 'name = 'cndok'> </form>"
End Function
'---------------- The paging link function ends --------------------
'---------------- Content display function starts --------------------
Sub showcontent
Dim I
I = 0
%>
<Table class = "tableborder" width = "90%" border = "0" align = "center" cellpadding = "3" cellspacing = "1">
<Form name = "form1" method = "Post" Action = "This. asp? Action = del ">
<Tr>
<TD colspan = "4" align = "center"> <B> Article Management </B> </TD>
</Tr>
<Tr>
<TD align = "center"> topic </TD>
<TD align = "center"> publisher </TD>
<TD align = "center"> release date </TD>
<TD align = "center"> select </TD>
</Tr>
<% Do while not Rs. EOF %>
<Tr>
<TD style = "padding-left: 6px"> <% = trim (RS ("newsname") %> </TD>
<TD align = "center"> <% = trim (RS ("addname") %> </TD>
<TD align = "center"> <% = RS ("adddate") %> </TD>
<TD align = "center"> <input name = "selectdel" type = "checkbox" id = "selectdel" value = <% = RS ("newsid ") % >></TD>
</Tr>
<%
I = I + 1
If I> = maxperpage then exit do
Rs. movenext
Loop
Rs. Close
Set rs = nothing
%>
<Tr>
<TD Height = "30" colspan = "4" align = "center">
<Input type = "Submit" name = "Submit" value = "delete selected articles"> select all
<Input type = "checkbox" name = "checkbox" value = "check all" onclick = "mm ()">
</TD>
</Tr>
</Form>
</Table>
<%
End sub
'---------------- Content display function end --------------------
%>
<Script language = JavaScript>
// ------- Trigger the function by selecting all buttons --------
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>
</Head>
<Body>
<Table width = "100%" border = "0" align = "center" cellpadding = "0" cellspacing = "0">
<Tr>
& Lt; TD Height = "100" valign = "TOP" & gt;
<%
'-------- Page starts ---------
Const maxperpage = 20
Dim totalput
Dim currentpage
Dim totalpages
Dim J
Dim SQL
If not isempty (Request ("page") then
Currentpage = CINT (Request ("page "))
Else
Currentpage = 1
End if
Set rs = server. Createobject ("ADODB. recordset ")
Rs. Open "select newsid, newsname, addname, adddate from shopxp_news order by adddate DESC", Conn, 1, 1
If err. Number <> 0 then
Response. Write "no data in the database"
End if
If Rs. EOF and Rs. bof then
Response. Write "<p align = 'center' class = 'contents'> you have not added an article! </P>"
Else
Totalput = Rs. recordcount
If currentpage <1 then
Currentpage = 1
End if
If (currentpage-1) * maxperpage> totalput then
If (totalput mod maxperpage) = 0 then
Currentpage = totalput \ maxperpage
Else
Currentpage = totalput \ maxperpage + 1
End if
End if
If currentpage = 1 then
Showcontent
Showpage totalput, maxperpage, "This. asp"
Else
If (currentPage-1) * maxperpage <totalput then
Rs. Move (currentPage-1) * maxperpage
Dim bookmark
Bookmark = Rs. bookmark
Showcontent
Showpage totalput, maxperpage, "This. asp"
Else
Currentpage = 1
Showcontent
Showpage totalput, maxperpage, "This. asp"
End if
End if
End if
'-------- Page ends ---------
%>
</TD>
</Tr>
</Table>
</Body>
</Html>
**************************************** *********************
1. Implement pagination using RS. Move (currentPage-1) * maxperpage method, and link the pagination and display the page content Code Function.
2. trigger events to select all and all check boxes.
3. Delete the database data of the selected check boxes.
-----------------------------------------
Knowledge point: when multiple form items with the same name are submitted, the value corresponding to this name is a combination of the form item values separated by commas, and can be operated in an array.