我做了一个活动服务器页面。它在门厅显示器上运行并显示会议。我将展示会议限制为 6 次。我的数据库中有 15 次会议。但门厅显示器一次只能显示 6 个会议。为了显示其余的会议,我想实现分页,但我不知道如何实现。
分页应自动进行。例如:显示前 6 次会议 10 秒,然后显示下一个 6 会议 10 秒,然后显示最近 3 次会议 10 秒,然后再次显示前 6 次会议,依此类推。
谁能帮我?我不知道该怎么做。 谢谢!
<%
set rs=Server.CreateObject("ADODB.recordset")
set rsRaum=Server.CreateObject("ADODB.recordset")
rs.Open "select distinct buchung_id, von, bis, abteilung, veranstalter, THEMA, THEMA_ENABLED " & _
" from RESERVIERUNGRAUM r " & _
" ,BUCHUNG b " & _
" where r.BUCHUNG_ID = b.ID " & _
" and von >= convert(date, getdate(), 4) " & _
" and von < convert(date, dateadd(day,1, GETDATE()), 4) " & _
" and BIS >= getdate() " & _
" and STORNO is null " & _
" order by von, bis" _
,objConn
lineMax = 6
lineCount = 1
do until rs.EOF
rsRaum.open "select DISPLAY_ENABLED from Buchung where ID = " & rs("buchung_id"), objConn
displayanzeige = rsRaum("DISPLAY_ENABLED")
rsRaum.close
rsRaum.open "select distinct g.BEZEICHNUNG " & _
"from GEBAEUDE g, ETAGE e, RAUM r " & _
"Where g.ID = e.GEBAEUDE_ID and e.GEBAEUDE_ID = r.GEBAEUDE_ID and r.ID = " & raum_id, objConn
GebaeudeBezeichnung = rsRaum("BEZEICHNUNG")
rsRaum.close
rsRaum.open "select bezeichnung from Raum where ID = " & raum_id, objConn
raumname = rsRaum("bezeichnung")
rsRaum.close
If lineCount > lineMax Then
exit do
End If
if ucase(displayanzeige) = "Y" or isnull(displayanzeige) then
%>
'
<tr "margin-bottom:100px" height="70" valign="top">
<td style="overflow:hidden;" class="<% =color%>"><% =thema %></td>
<td class="<% =color%>"><% =Hinweistext %></td>
<td align="center"; class="<% =color%>"><% =FormatDateTime( rs("von"), 4)%></td>
<td align="center"; class="<% =color%>"><% =FormatDateTime( rs("bis"), 4) %></td>
<td align="center"; class="<% =color%>"><% =GebaeudeBezeichnung %><br></td>
<td align="center"; class="<% =color%>"><% =raumname %><br></td>
</tr>
'
<%
rs.moveNext
loop
rs.close
%>
您需要做几件事:
-
使脚本能够采用 GET 参数,该参数指定要显示的"页面"。 像这样:
dim page = Request.QueryString("page") dim next_page = page + 1 dim num_pages = [ you'll want to get this from your database table ]
-
修改数据库查询以适当地使用新的变量页
-
在页面上生成一些javascript,这将导致浏览器在10秒后为下一页加载新的URL。 如果它超过总页数,请换行到开头。
<script type="text/javascript"> function doNextPage(){ window.location = "/my/display.asp?page=<% Response.Write next_page mod num_pages %>"; } function doNextPageDelayed(){ setTimeout("doNextPage()", 10000); } </script>
-
您还需要使函数"doNextPageDelayed"实际运行。 为此,请在 HTML 的 body 标记中插入一些代码。
<body onload="doNextPageDelayed()"> </body>
我发现这个链接有助于记住如何导致运行 javascript 函数的延迟:http://www.geekpedia.com/KB55_How-do-I-make-a-JavaScript-function-wait-before-executing-(sleep-or-delay).html