1

現在の日の予約を表示する Active Server Page があります。PageSize を 2 に設定したので、より多くのレコードがある場合、ディスプレイには片面につき 2 つの予約のみが表示されます。実際には、レコードセットに 8 つの予約があるため、ASP は 4 つのページを作成します。

それを説明するために、スナップショットを作成しました。

画面

ご覧のとおり、4 つのページがあり、それらを切り替えることができます。iで>次の 2 つの予約を<取得し、i で前の 2 つの予約を取得できます。

私が必死に必要としているのは、10 秒間隔で自動的にページを変更することです。例: 最初のページを 10 秒間表示してから、次のページに切り替えて 10 秒間表示します。最後のページに到達した場合は、最初のページからやり直してください。

10秒ごとにページを変更するタイマーと、最後のページに達した場合に最初のページから再び開始するループのようなものが必要だと思います。しかし、私はそれを行う方法がわかりません。

誰かが私を助けてくれたらうれしいです。

これまでの私のコードの一部:

Option Explicit
'declare variables
Dim Currpage, pageLen, lastNumber, PageRem, PageTen
Dim connection, recordset, sSQL, sConnString, next10, prev10, P
Dim RSPrevPage, RSNextPage, start
Dim thema, rsRaum, displayanzeige, bstatus, raum_id, GebaeudeBezeichnung, HinweisText, KOPPELBESTUHLUNG_ID, raumname
'Get the current page the user is on, if it's the first time they
'visit and the variable 'PageNo' is empty, then 'CurrPage' gets set to 1
'Else the current page variable 'CurrPage' is set to the page number requested
If IsEmpty(Request.Querystring("PageNo")) then
CurrPage = 1
Else
CurrPage = Cint(Request.Querystring("PageNo"))
End If

'the two functions below return the next 10 and prev 10 page number
Function getNext10(num)
pageLen = len(num)
If pageLen = 1 Then
next10 = 10
ElseIf pageLen>1 Then
pageRem = 10
pageTen = right(num, 1)
next10 = num + pageRem - pageTen
End If
getNext10 = next10
End Function

Function getPrev10(num)
pageLen = len(num)
If pageLen = 1 then
prev10 = 1
ElseIf pageLen>1 then
lastNumber = right(num, 1)
prev10 = num - lastNumber - 10
End If
If prev10 = 0 then
prev10 = 1
End If
getPrev10 = prev10
End Function


 Do Until Recordset.AbsolutePage <> CurrPage OR Recordset.Eof


 Recordset.MoveNext
 Loop


'the next 2 lines setup the page number for the "previous" and "next" links
RSNextPage = CurrPage + 1
RSPrevPage = CurrPage -1

'find out the number of pages returned in the recordset
'if the Next10 page number is greater than the recordset page count
'then set Next10 to the recordset pagecount
If Next10 > Recordset.PageCount Then
Next10 = Recordset.PageCount
End If

'the variable start determines where to start the page number navigation
' i.e. 1, 10, 20, 30 and so on. 
If prev10 = 1 AND next10 - 1 < 10 Then
start = 1
Else
start = Next10 - 10
If right(start, 1) > 0 Then
start = replace(start, right(start, 1), "0")
start = start + 10
End If
End If

'This checks to make sure that there is more than one page of results
If Recordset.PageCount > 1 Then
'Work out whether to show the Previous 10 '<<' 
If currpage > 1 Then
response.write("<a href=""paging.asp?PageNo=" & Prev10 & """><<</a> ")
End If
'Work out whether to show the Previous link '<' 
If NOT RSPrevPage = 0 then
response.write("<a href=""paging.asp?PageNo=" & RSPrevPage & """><</a> ")
End If

'Loop through the page number navigation using P as our loopcounter variable 
For P = start to Next10

If NOT P = CurrPage then
response.write("<a href=""paging.asp?PageNo=" & P & """>" & P & "</a> ")
Else
'Don't hyperlink the current page number 
response.write(" <b>" & P & " </b>")
End If
Next
'this does the same as the "previous" link, but for the "next" link
If NOT RSNextPage > Recordset.PageCount Then
response.write("<a href=""paging.asp?PageNo=" & RSNextPage & """>></a> ")
End If

'Work out whether to show the Next 10 '>>' 
If NOT Next10 = Recordset.PageCount Then
response.write(" <a href=""paging.asp?PageNo=" & Next10 & """>>></a>")
End If
4

2 に答える 2

2

次のようにメタ リフレッシュを使用します。

<meta http-equiv="refresh" content="10;URL=nextPage.asp" />

10content秒数で、;その後にが続きURL=<url>ます。これは通常の HTML タグで、<HEAD>. ASP 経由で変更できる URL 自体。

于 2012-12-11T07:54:54.177 に答える
0

最後のセクション (「次の」リンクを配置するかどうかを既に決定している部分) では、ASP を使用してスクリプト タグを記述し、JavaScript 関数を呼び出します。

(from the last section of your code example above)
'Work out whether to show the Next 10 '>>' 
If NOT Next10 = Recordset.PageCount Then
    response.write(" <a href=""paging.asp?PageNo=" & Next10 & """>>></a>")
    response.write("<script type=""text/javascript"" language=""javascript"">goToNextPage(" & Next10 & """);</script>")
End If

これにより、ページは JavaScript 関数「goToNextPage(pageNumber);」を呼び出します。Next10 値を受け入れます。このスクリプト タグを出力ストリームに書き込むのは、既に「次の」リンクを書き込んでいる場合のみであるため、表示する別のページがある場合にのみ呼び出されます。

次に、HEAD セクションに、リクエストを処理するための JavaScript 関数を追加します。

<head>
<script type="text/javascript" language="javascript">
/*
This function accepts the requested page number and then waits 10 seconds before redirecting back to itself with the new "pageNo" value in the query string
*/
function goToNextPage(nextPageNumber)
{
    setTimeout(function(){window.location='paging.asp?pageNo='+nextPageNumber;},10000);
}

</script>
</head>
于 2014-07-02T18:37:31.330 に答える