php - How to limit row number in pagination with select option -


i have page pagination. want implement new feature: when select number of rows in select box. webpage show matching data. tried ajax. limit variable has been send, controller can not process. can me!

here sample image

html code:

<form method="post"> <select name="select_limit" id="select_limit">      <option value="10">10</option>      <option value="100">100</option> </select> </form> 

ajax code:

$(document).ready(function() {     $('#select_limit').change(function() {         var limit = $("#select_limit option:selected").val();         $.ajax({             type: "post",             cache:false,             url:"<?php //link controller ?>",             //send data             data:{'limit': limit},             });     }); }); 

and in controller, limit variable same normal code:

$limit = $_post['select_limit']; 

maybe need not use ajax, can try:

$(document).ready(function() {     $('#select_limit').change(function() {         $(this).closest('form').submit();     }); });  // use method, , form action should same url pagination link  <form method="get">   <select name="select_limit" id="select_limit">      <option value="10" <?php echo $limit == 10 ? 'selected' : ''?>>10</option>      <option value="100" <?php echo $limit == 100 ? 'selected' : ''?>>100</option>   </select> </form> 

this sloution refresh page.

edit

==================================================================

and add &limit=<?php echo $limit?> link like:

 <li class="<?php  if($crr_page=$i) echo 'active' ?>">       <a href="<?php echo $this->url->get('dashboard/list-user') ?>?page=<?php echo $i ; ?>&txt_keyword=<?php echo $keyword; ?>&limit=<?php echo $limit?>"><?php  echo $i  ?></a>  </li> 

Comments