Et andet eks hvor man tæller antal ord der skal vises pr. side:
<% ' Paging af tekst ' Paging tekst ' Paging text
%> <HTML> <HEAD> <TITLE></TITLE> </HEAD> <BODY> <TABLE BORDER="0" WIDTH="100%"> <TR> <TD> <% 'Functions function countWords(str) arr = Split(str," ") countWords = UBound(arr) + 1 set arr = nothing end function
function cutToWord(str,antal) arr = Split(str," ") tmp = "" for i = lbound(arr) to antal 'Skal være tom next for i = antal to ubound(arr) tmp = tmp & arr(i) & " " next cutToWord = tmp set arr = nothing set tmp = nothing end function
function cutAfterWord(str,antal) arr = Split(str," ") tmp = "" for i = lbound(arr) to antal-1 tmp = tmp & arr(i) & " " next cutAfterWord = tmp set arr = nothing set tmp = nothing end function 'End function
Set Conn = Server.CreateObject("ADODB.Connection") Set rs = Server.CreateObject("ADODB.RecordSet") Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& server.mappath("../db5.mdb")
id = Request("id") id = 2 'Kræver et ID som er den arkitek eller den post hvor den lange tekst er. Så for test er det hardcodet. subpage = Int(Request("subpage")) if subpage = "" then subpage = 0 'Definer antal ord pr side maxOrdPrSide = 10
SQL = "SELECT * FROM nyhederTB WHERE ID = " & id Set rs = Conn.Execute(SQL)
if maxOrdPrSide < maxWords then strText = cutToWord(strText, maxOrdPrSide*subpage) if maxOrdPrSide < countWords(strText) then strText = cutAfterWord(strText, maxOrdPrSide) end if end if
Response.Write strText
Response.Write "<br><br>"
siderIalt = Int(maxWords/maxOrdPrSide)+1 for i = 0 to siderIalt-1 Response.Write "<a href=""?subpage=" & i &"&id="&id&""">"& i+1 & "</a>" Response.Write " " next
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.