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

  • SEARCH
  • Home
  • 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 3617342
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:36:44+00:00 2026-05-18T22:36:44+00:00

my pagination works good but I’m not able to understand how generate a fixed

  • 0

my pagination works good but I’m not able to understand how generate a fixed number of links to the pages.
For example, I need to have 5 fixed links in this way: 1 – 2 – 3 – 4 – 5 >
if I click on the third page I will see always 5 links: < 3 – 4 – 5 – 6 -7 >

Now with my algorithm I’m only able to generate all the links, but I have no idea how create what I have explained above.
This is my code(only for href generation):

<div class="pageBoxRight">
 <c:if test="${param.pageNumber > 1}">
 <a href="javascript: previousRecords();" class="previous"><em>previous</em></a>
 </c:if>
 <c:forEach var="i" begin="1" end="${tot + 1}" step="1" varStatus ="status">
 <a href="javascript: goToPage(${i});" id="paginator${i}" class="pageNumber"><span class="pageNumberRight">${i}</span></a>
 </c:forEach>
 <c:if test="${param.pageNumber < tot}">
 <a href="javascript: nextRecords();" class="next"><em>next</em></a>
 </c:if>
</div>

Can someone help me? Thanks a lot.

  • 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-18T22:36:45+00:00Added an answer on May 18, 2026 at 10:36 pm

    It get complicated.

    <c:set var="p" value="${param.pageNumber}" /> <%-- current page (1-based) --%>
    <c:set var="l" value="5" /> <%-- amount of page links to be displayed --%>
    <c:set var="r" value="${l / 2}" /> <%-- minimum link range ahead/behind --%>
    <c:set var="t" value="${tot}" /> <%-- total amount of pages --%>
    
    <c:set var="begin" value="${((p - r) > 0 ? ((p - r) < (t - l + 1) ? (p - r) : (t - l)) : 0) + 1}" />
    <c:set var="end" value="${(p + r) < t ? ((p + r) > l ? (p + r) : l) : t}" />
    
    <c:forEach begin="${begin}" end="${end}" var="page">
        ${page}...
    </c:forEach>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am using zend paginator in my app.pagination works well but i get this
HI i have a working php based pagination which works fine, but when i
I build a quick pagination from scratch it kind of works, but for the
I have a trouble with kaminari pagination and bootstrap styles. Pagination works fine, but
I use the pagination helper from CodeIgniter and it works. But when I see
Django Endless Pagination works perfectly fine right until I use template inheritance. views.py: from
I am using codeigniter and its pagination class. It works perfectly and it looks
I just got pagination to work on my site, but I wanted to use
I started using Zend_Paginator, it works everything fine but I noticed that there is
I have implemented pagination to my data, but the problem is I only have

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.