I want use checkbox's value, but I have a problem. I am not submitting the form, using AJAX records are changing. When I click checkbox, courses checkbox value changes, and if I uncheck checkbox the courses combobox will be same as before. My page have pagination, now I have problem, when I click pagination my combobox's value will be same as before and no. of records donot reflect expect of first-page. I want to preserve checkbox's value just like $_POST and $_REQUEST.
Refer images below.

Recommended Answers

All 3 Replies

I think that your safest bet is to set an onclick handler to those page number links, without removing the href attribute, something like this:

<a href="?page=2" onclick="location='?page=2&option='+option.checked;return false">2</a>

In PHP, you than have $_GET. Make the var 'option' in javascript the input element.

I think that your safest bet is to set an onclick handler to those page number links, without removing the href attribute, something like this:

<a href="?page=2" onclick="location='?page=2&option='+option.checked;return false">2</a>

In PHP, you than have $_GET. Make the var 'option' in javascript the input element.

I am using different pagination function.
Here is the code..

function pagination($count, $perPage, $id, $page, $max_links)
{
  $total_pages = ceil($count/$perPage);
  if($page) 
  {
  if($page >10)
  { 
  $prev10 = ' &nbsp; <a style = "color: #0000CC" href="'.pagination_link($id, ($page-10)).'" ><strong>Previous 10</strong></a> &nbsp; '; 
  }
  if($page>1)
  {
  $prev = ' &nbsp; <a style = "color: #0000CC" href="'.pagination_link($id, ($page-1)).'" ><strong>Previous</strong></a> &nbsp; '; 
  $first = '<a href="'.pagination_link($id, (1)).'">&lt;&lt;</a>'; 
  }
  }
  if($page<$total_pages)
  { 
  if($total_pages-$page>=10)
  $next10 = ' &nbsp; <a style = "color: #0000CC" href="'.pagination_link($id, ($page+10)).'"><strong>Next 10</strong></a> &nbsp; '; 
  else
  $next10 = ' &nbsp; <a style = "color: #0000CC" href="'.pagination_link($id, ($page+$total_pages-$page)).'"><strong>Next 10</strong></a> &nbsp; '; 
  $next = ' &nbsp; <a style = "color: #0000CC" href="'.pagination_link($id, ($page+1)).'"><strong>Next</strong></a> &nbsp; '; 
  $last = ' &nbsp; <a href="'.pagination_link($id, $total_pages).'">&gt;&gt;</a> &nbsp; ';
  }
  echo $first;
  echo $prev10;								  
  echo $prev;
  $loop = 0;
  if($page >= $max_links) 
  {
  $page_counter = ceil($page - ($max_links-1));
  } 
  else
  {
  $page_counter = 1;
  }
  if($total_pages < $max_links)
  {
  $max_links = $total_pages;
  }
  do 
  { 
  if($page_counter == $page) 
  {
  echo ' &nbsp; <strong style="color: #CC0033">'.$page_counter.'</strong> &nbsp; '; 
  } 
  else 
  {
  echo '<a style = "color: #000000" href="'.pagination_link($id, ($page_counter)).'">'.$page_counter.'</a> &nbsp; ';
  } 
  $page_counter++; $current_page=($page_counter+1);
  $loop++;
  } while ($max_links > $loop);
  echo $next;	
  echo $next10;
  echo $last;
 }

Where I can insert your above code..

Well, you could either change pagination_link() to use window.location, or you could set (everywhere you echo a link) the onclick to something like "location='$pagination_link&option='+option.checked;return false" , assuming $pagination_link is what your function returns.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.