jquery - php update database when checkbox is clicked -


i displaying data database , refresh results when user clicks on specific checkbox.

i have set name attribute checkbox , tried use isset couldn't work don't have form , displaying results on same page using pagination. how load new results when checkbox clicked without using <form>?

here javascript used page refreshed(not results)

<script type="text/javascript">     var reloading;      function checkreloading() {         if ( window.location.hash == "#autoreload" ) {             reloading=settimeout("window.location.reload();", 100);             document.getelementbyid("reloadcb").checked=true;         }     }      function toggleautorefresh( cb ) {         if ( cb.checked ) {             window.location.replace("#autoreload");             reloading=settimeout("window.location.reload();", 100);         } else {             window.location.replace("#");             cleartimeout( reloading );         }     }      window.onload=checkreloading; </script> 

and here php first tried $_post check if checkbox selected couldn't work , tried $_get , again same thing. problem below code shows results table 2 ignoring table 1 if checkbox selected.

try {         if ( isset( $_get["size"] ) ) {         $paginate = new pagination($page, 'select * test1 order id desc', $options); exit();     } else {          $paginate = new pagination($page, 'select * test2 order id desc', $options);     } } catch( paginationexception $e ) {     echo $e;     exit(); } 

the html

<input type="checkbox"  name="size" onclick="toggleautorefresh(this);" id="reloadcb"> 

hi try this:

function toggleautorefresh( cb ) {     if ( cb.checked ) {         window.location.replace("#autoreload");         reloading=settimeout(function(){             // current url , append parameter             var url = window.location.href + "?size=1";             window.open(url, '_self'); //open url             }, 100);     } else {         window.location.replace("#");         cleartimeout( reloading );     } } 

hope helps.

edited include second perimeter window.open


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -