This tutorial shows how to let the visitor select the number of records per page from a List Box using Tom Muck’s Horizontal Looper Extension.
Since there will be probably be several pages on your site with this behaviour, we are going to use a Session to store the visitor’s choice so it will be valid on all the pages, instead of the visitor having to set the number of records on each page they visit.
Set up your recordset as normal and apply the Horizontal Looper behaviour
Insert a form with a list box.
<form name="form1" method="post" action="yourpage.asp">
Records per Page
<select name="select" >
<input type="submit" name="Submit" value="Go">
In your option values, use the number of records divided by the number of columns you want on your page. If you have four columns, then 8 records per page is a value of 2.
Next, set the session –
If Request.Form("select") ="" then
If Session("paging") <>"" then
Session("paging") = Session("paging")
If Request.Form("select") <> "" then
Session("paging") = Request.Form("select")
This also prevents the Session being set to zero when the visitor pages through the records. If the visitor enters a new value, the Session will update to that value.
Now you have to modify the Horizontal Looper code.
Change the code to set the number of rows (the default value here is 8 to have 2 rows of 4 columns, but you can make that 9 and change the multiplier further down from 4 to 3 to give 3 rows of 3 columns)
If Session("paging") ="" then
HLooper1__numRows = 8
HLooper1__numRows = 4 * Session("paging")
HLooper1__index = 0
Recordset1_numRows = Recordset1_numRows + HLooper1__numRows
Now the final part. Modify the code as follows,
startrw = 0
endrw = HLooper1__index
numberColumns = 4
if Session("paging") = "" then
numrows = 2
numrows = Session("paging")
Make sure you set the numberColumns and numrows to the default values you set earlier.
It’s that easy! You can apply the first, next, previous behaviours as normal.