programming-examples/asp/Strings/Dividing a long string to pages.asp
2019-11-18 14:25:58 +01:00

30 lines
1.2 KiB
Plaintext

function pageString(str,Nrow)'the string to act upon and number of rows in page--- this function cuts a string to "pages"=divs
res="<div id='page0' style='display:inline'>"'result string
rowsRA=split(str,"<br>")
pgI=0'page counter- counts the number of pages the string was divided to
i=0
for each row in rowsRA
'alert (i)
if (i mod Nrow=0) and (not i< Nrow) then
res=res&"<p>"
if (pgI-1)>=0 then
res=res&"<input type='button' onclick="&chr(34)&"page"&pgI&".style.display='none';page"&pgI-1&".style.display='inline'"&chr(34)&"value='prev.'> "
end if
res=res&"<input type='button' onclick="&chr(34)&"page"&pgI&".style.display='none';page"&pgI+1&".style.display='inline'"&chr(34)&"value='next'> "
pgI=pgI+1
res=res&"</div>"&chr(13)&"<div id='page"&pgI&"' style='display:none' >"&chr(13)
end if
res=res&rowsRA(i)&"<br>"&chr(13)
i=i+1
next
res=res&"<input type='button' onclick="&chr(34)&"page"&pgI&".style.display='none';page"&pgI-1&".style.display='inline'"&chr(34)&"value='next'> "
res=res&chr(13)&"</div>"&chr(13)
pageString=res
end function