ajax php pagination wont show active page -


i working on php ajax pagination.

the problem wont ad class="highlightactivepage" proper.

if click on 1 - 2 - 3 , works fine , highlight number 3 if im on page 3.

but click on page 4 highlights page 5 instead, etc.

not sure if loop wrong, here code:

if (paginationhtml == "")         {              paginationhtml += "<ul>";              if (adresultsdata.show_first_text == 1)             {                 paginationhtml += "<li><a href='#' onclick='fetchresults(1);'>first</a></li>";               }              if (adresultsdata.show_previous_text == 1)             {                 paginationhtml += "<li><a href='#' onclick='fetchresults(" + (adresultsdata.current_page - 1) + ");'>prev</a></li>";                 }              (var = 0; < adresultsdata.pages.length; i++)             {                 if (adresultsdata.current_page == (i + 1))                 {                     paginationhtml += "<li><a href='#' class='highlightactivepage' onclick='fetchresults(" + adresultsdata.pages[i] + ");'>" + adresultsdata.pages[i] + "</a></li>";                 }                 else                 {                     paginationhtml += "<li><a href='#' onclick='fetchresults(" + adresultsdata.pages[i] + ");'>" + adresultsdata.pages[i] + "</a></li>";                 }              }              if (adresultsdata.show_next_text == 1)             {                 paginationhtml += "<li><a href='#' onclick='fetchresults(" + (adresultsdata.current_page + 1) + ");'>next</a></li>";                 }              if (adresultsdata.show_last_text == 1)             {                 paginationhtml += "<li><a href='#' onclick='fetchresults(" + adresultsdata.number_of_pages + ");'>last</a></li>";                }              paginationhtml += "</ul>";             paginationhtml += pagespan.innerhtml = "<br>page " + adresultsdata.current_page + " of " + adresultsdata.number_of_pages;          } 

php

    $numberofpages = $results['pages']; $currentpage = $results['currentpage'];    if ($currentpage != 1 && $currentpage != 2) {$showfirst = 1;} else $showfirst = 0;  if ($currentpage != 1) {$showprevious = 1;} else $showprevious = 0;  if ($currentpage != $numberofpages) {$shownext = 1;} else $shownext = 0;  if ($currentpage != $numberofpages && $currentpage != ($numberofpages - 1)) {$showlast = 1;} else $showlast = 0;    if ($currentpage <= 5 && $numberofpages <= 5 || $numberofpages <= 5) {$startingpage = 1;} else if ($currentpage == 1 || $currentpage == 2) {$startingpage = 1;} else {$startingpage = $currentpage - 2;}    $pagenumbers = []; ($i = $startingpage; $i < ($startingpage + 5) && $i <= $numberofpages; $i++) {     $pagenumbers[] = $i; } 

$pagesstring = implode(", ", $pagenumbers); $listingsstring = implode(", ", $listingsarray);

$jsonstring = <<< end { "resultstotal" : $numberofresults, "listings" : [$listingsstring], "number_of_pages" : $numberofpages, "current_page" : $currentpage,

thanks!


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -