473,406 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

sample code for dynamic pagination in javascript needed urgent

nirmalsingh
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 5159
acoder
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

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

Similar topics

1
by: Kruq | last post by:
Is it possible to use pagination with DataList? Can't find it.. :( Kruq
1
by: Ed Jay | last post by:
I generate a DHTML page (a medical report) with dynamically generated text based on user input (answers to questions). The page length changes dynamically. I desire that when the page is printed...
4
by: Ed Jay | last post by:
I generate a DHTML page (a medical report) with dynamically generated text based on user input (answers to questions). The page length changes dynamically. I desire that when the page is printed...
9
by: Peter Michaux | last post by:
Hi, Does a parser generator exist that generates JavaScript code? Most parser generators generate C or Java code. Thanks, Peter
1
by: doemon | last post by:
Hi, I'm working on a pagination control and I need to dynamically rerender a treeview to display the next set of nodes depending on which page we're on. For example, page 1 will dispaly only...
3
nirmalsingh
by: nirmalsingh | last post by:
hi everybody, as in ( the scripts) page below, i want to do some pagination in c#. for example : <<previous>> 1 2 3 4 5 . . . . . 51 52 53 <<next>> help me plz.. i have build...
1
by: Ismail | last post by:
Hello, What needs to be done to get gridview pagination to work without javascript ie browser has javascript disabled. Is their a property in the gridview control that can be set to do...
9
by: pbd22 | last post by:
Hi. This is just a disaster management question. I am using XMLHTTP for the dynamic loading of content in a very crucial area of my web site. Same as an IFrame, but using XMLHTTP and a DIV. I...
3
by: tokcy | last post by:
hi everyone, i am creating dynamic row in a table using javascript its working fine and now i want to create more than 1 table using javascript which is dynamic its also working fine but when i am...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.