Hej,
I følgende script kan man page i recordsettet med hyperlinks til "forrige"
og "næste" side. Jeg ønsker nu at få en "sidste" side hyperlink ind, men jeg
kan ikke få den til at fungere uanset hvad jeg har fantasi til at foreslå.
Hvad gør jeg forkert?
mvh ulrik
<%@ Language=VBScript %>
<%
Option Explicit
Response.Expires = 0
%>
<!--#include virtual="/css/adovbs.inc"-->
<%
Const intPageSize = 1
Dim intCurrentPage, objConn, objRS, strQ
Dim intTotalPages, intI
If Request.QueryString = "" Then
intCurrentPage = 1
Else
intCurrentPage = Cint(Request.QueryString("CurrentPage"))
Select Case Request.QueryString("Submit")
Case "Previous"
intCurrentPage = intCurrentPage - 1
Case "Next"
intCurrentPage = intCurrentPage + 1
Case "Last"
intCurrentPage = intTotalPages 'Dette nægter den at godtage - hvorfor?
End Select
End If
'Connection deklareres
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" &
Server.Mappath("mydb.mdb") & ";"
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.CursorLocation = adUseClient
objRS.CursorType = adOpenStatic
objRS.CacheSize = intPageSize
strQ = "SELECT * FROM news ORDER BY dato DESC"
objRS.Open strQ, objConn, , , adCmdText
objRS.PageSize = intPageSize
If Not(objRS.EOF) Then objRS.AbsolutePage = intCurrentPage
intTotalPages = objRS.PageCount
%>
<html>
<body>
<%
For intI = 1 to objRS.PageSize
Response.Write objRS("dato") & "<br>"
Response.Write objRS("overskrift") & "<br>"
objRS.MoveNext
If objRS.EOF Then Exit For
Next
objRS.Close : objConn.Close
Set objRS = Nothing : Set objConn = Nothing
%>
<br>
<%
If intCurrentPage > 1 Then %>
<a href="<%= Request.ServerVariables("SCRIPT_NAME")%>?CurrentPage=<%=
intCurrentPage%>&Submit=Previous">< Previous</a>
<% End If%>
[Side <%= intCurrentPage %> af <%= intTotalPages %>]
<% If intCurrentPage <> intTotalPages Then %>
<a href="<%= Request.ServerVariables("SCRIPT_NAME")%>?CurrentPage=<%=
intCurrentPage%>&Submit=Next">Next ></a>
<a href="<%= Request.ServerVariables("SCRIPT_NAME")%>?CurrentPage=<%=
intCurrentPage%>&Submit=Last">Last >|</a>
<% End If %>
</body>
</html>
|