Monday, October 25, 2010

Home Grown : 6. Pagination with page jump

Today we're going to add a small snippet of code to our previous paginate example and we're going to get page Jump functionality. Now you may ask why is this important? Simply when you have a large number of records arranged sequentially and the user has some general idea where he wants to go so he can just enter an approximate page number and jump there thus saving him so many scrolls through records of literally no importance to him.

How do we implement this?
It's really simple as we can see that the pagination PHP code passes the page number as a GET parameter in the URL. So we code a small form for user to enter the page number to and we name the input field as page and set the request method as GET. So when this form is submitted the page value that the user has entered will be available to the PAGINATE script in the form of Page parameter.

Now this example just stirs the surface, and there are so many things that we can add here. Like automatically taking current page number in the page field. Or clicking clear should clear the page field and take us to first page. We can implement these things as needed. Using the page jump facility our web page becomes very navigational. Next we'll handle the autosuggest functionality.

Download the Project from

No comments:

Post a Comment