469,623 Members | 1,800 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,623 developers. It's quick & easy.

sample code for dynamic pagination in javascript needed urgent

218 100+
hi everybody,
as in ( the scripts) page below, i want to do some pagination in javascript.
for example : <<previous>> 1 2 3 4 5 . . . . . 51 52 53 <<next>>
help me plz..
Jan 17 '07 #1
1 4942
16,027 Expert Mod 8TB
What will you use the pagination code for? If it's to link to pages showing data from a database involving server code, e.g. like this forum, an enquiry system, job search results, etc., you might be better off writing this on the server side.

If you still require it in javascript, here are some ideas:
1. Find your total records (whatever they may be).
2. How many will you display per page? 10? 20? Decide.
3. Divide 1 by 2 to get the number of pages. Use the ceil function to get a rounded number upwards.
4. Decide how many numbers to display, e.g. 1 - 5 then ... followed by the last three numbers, etc.
5. The page that you are on should be highlighted. This can be determined by the number that you pass in the URL to determine what page to display.
6. Each page link should begin from 1 + (the number of records per page multiplied by (n-1) with n being the page number, so this will mean for example that page 1 starts from record 1 and page 2 from records 11 (if you're displaying 10 records per page).

See how you get along with that. This should work for any language if you know the basics. There will probably be other ways, but this is worth a try.
Jan 17 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Kruq | last post: by
1 post views Thread by Ed Jay | last post: by
9 posts views Thread by Peter Michaux | last post: by
1 post views Thread by doemon | last post: by
1 post views Thread by Ismail | last post: by
9 posts views Thread by pbd22 | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.