Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 691443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:32:40+00:00 2026-05-14T02:32:40+00:00

How to generate page numbers like the below using javascript/jquery? If the 5 th

  • 0

How to generate page numbers like the below using javascript/jquery?

If the 5 th page is selected i have to show 3,4 and 6,7 and also 1,last page with prev,next…
Any suggestion….

EDIT:

How to work with json data that use these pagination div? (ie) My json data contains 50 records
I want to 10 in page 1 and so on… How to paginate json data with these numbers…

I want a jquery function to pass currentpageno,lastpagenumber and the function should generate me page numbers like the below for me

If it is the first page

istpage

If it is in the middle,

Pager

If it is the last page,

lastpage

Second EDIT:

I have tried this function but doesn’t seem to get the desired result

function generatePages(currentPage, LastPage) {
    if (LastPage <= 5) {
        var pages = '';
        for(var i=1;i<=5;i++)
        {
            pages += "<a class='page-numbers' href='#'>" + i + "</a>"
        }
        $("#PagerDiv").append(pages);
    }
    if (LastPage > 5) {
        var pages = '';
        for (var i = 1; i <= 5; i++) {
            pages += "<a class='page-numbers' href='#'>" + i + "</a>"
        }
        $("#PagerDiv").append(pages);
    }
}

I have the lastPage and currentPage values please help me out getting this…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T02:32:40+00:00Added an answer on May 14, 2026 at 2:32 am

    What you are looking for is called “pagination” and there’s (as always) a jQuery plugin that does the job for you:

    http://d-scribe.de/webtools/jquery-pagination/demo/demo_options.htm

    (Download it here)


    Edit: Since you don’t seem to be able to get it working, here is one way (of several different) how you can use the plugin.

    Step 1: Generate markup from your JSON-data like the following:

    <div id="display">
        <!-- This is the div where the visible page will be displayed -->
    </div>
    
    <div id="hiddenData">
        <!-- This is the div where you output your records -->
        <div class="record">
            <!-- create one record-div for each record you have in your JSON data -->
        </div>
        <div class="record">
        </div>
    </div>
    

    The idea is to copy the respective record to the display div when clicking on a page-link. Therefore, the plugin offers a pageSelect-callback function. Step 2 is to implement this function, for instance:

    function pageselectCallback(pageIndex, jq){
        // Clone the record that should be displayed
        var newContent = $('#hiddenData div.record:eq('+pageIndex+')').clone();
        // Update the display container
        $('#display').empty().append(newContent);
        return false;
    }
    

    This would mean that you have one page per record. If you want to display multiple records per page, you have to modify the above function accordingly.

    The third and final step is to initialize the whole thing correctly.

    function initPagination() {
        // Hide the records... they shouldn't be displayed
        $("#hiddenData").css("display", "none");
        // Get the number of records
        var numEntries = $('#hiddenData div.result').length;
        // Create pagination element
        $("#pagination").pagination(numEntries, {
            num_edge_entries: 2,
            num_display_entries: 8, // number of page links displayed 
            callback: pageselectCallback,
            items_per_page: 1  // Adjust this value if you change the callback!
        });
    }
    

    So, you just have to generate the HTML markup from your JSON data and call the init-function afterwards.

    It’s not that difficult, is it?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 539k
  • Answers 539k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Alright, so from what i've gathered you've got a collection… May 17, 2026 at 2:14 am
  • Editorial Team
    Editorial Team added an answer Or is it already thread safe since "name" is a… May 17, 2026 at 2:14 am
  • Editorial Team
    Editorial Team added an answer right click on the referenced dlls and check if copy… May 17, 2026 at 2:14 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have the script below which works well, i.e. it generates a chart on
I am using the get method to perform some operation like, approve, markasspam, delete,
I have a table that lists users that are registered at my website. The
I just learn Ruby, and I wonder how to generate Reports and Invoices (with
I have list of categories that is contained in li 's on one column
I have a website that grabs a random entry from a database and displays
I have a pagination function that I use for my database search that limits
I have a question regarding the creation of Auto Dynamic text boxes within PHP.
We began a project using WebForms, and developed a somewhat complex portal system to
I'm writing an app which for various reasons involves Internet Explorer (IE7, for the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.