title: How to save / keep checkbox checked?
body: <p>I'm working on web application project (clinic &amp; laboratory) it's all about sending tests. i used code below to select the test category first then the test name which related in this category. but when i moving to another category. the old one with selected input will reset . who to save them temporary before sending it to data base? i'm still newbie at ajax.</p>
  
  <p><a href="https://i.stack.imgur.com/7WVlN.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7WVlN.gif" alt="enter image description here"></a></p>
  
  <pre><code>    &lt;?php
  // Dashboard page
          include('CONFIG.PHP');
          $query = "SELECT * FROM `test_categories` ORDER BY `test_categories`.`CATEGORY_ID` DESC";
          $statement = $connect-&gt;prepare($query);
          $statement-&gt;execute();
          $result = $statement-&gt;fetchAll();
          foreach($result as $row)
          {
          ?&gt;
          &lt;div class=""&gt;
          &lt;label&gt;
          &lt;input  type="checkbox" class="common_selector category" value="&lt;?php echo $row['CATEGORY_NAME']; ?&gt;"&gt; 
          &lt;?php echo $row['CATEGORY_NAME']; ?&gt;&lt;/label&gt;
          &lt;/div&gt;
          &lt;?php
          }
          ?&gt;
  
      ===============================================
          &lt;script&gt;
          $(document).ready(function(){
  
              filter_data();
  
              function filter_data()
              {
                  $('.filter_data').html('&lt;div id="loading" style="" &gt;&lt;/div&gt;');
                  var action = 'fetch_data';
                  var brand = get_filter('category');
                  $.ajax({
                      url:"FUNCTIONS.PHP",
                      method:"POST",
                      data:{action:action, category:category},
                      success:function(data){
                          $('.filter_data').html(data);
                      }
                  });
              }
  
              function get_filter(class_name)
              {
                  var filter = [];
                  $('.'+class_name+':checked').each(function(){
                      filter.push($(this).val());
                  });
                  return filter;
              }
  
              $('.common_selector').click(function(){
                  $('input').not(this).prop('checked', false);
                  filter_data();
              });
          });
          &lt;/script&gt;
  
  
      ==========================================
      // FUNCTIONS PAGE
  
          if(isset($_POST["action"]))
          {
              include 'CONFIG.PHP';
              $query = "";
              if(isset($_POST["category"]))
              {
                  $category_filter = implode("','", $_POST["category"]);
                  $query .= "
                  SELECT * FROM `tests` WHERE TEST_CATEGORY = ('".$category_filter."') ORDER BY `tests`.`TEST_ID` DESC
                  ";
              }
  
  
              $statement = $connect-&gt;prepare($query);
              $statement-&gt;execute();
              $result = $statement-&gt;fetchAll();
              $total_row = $statement-&gt;rowCount();
              $output = '';
              if($total_row &gt; 0)
              {
                  foreach($result as $row)
                  {
                      $output .= "
  
  
                      &lt;div class='TEST'&gt;
          &lt;input id='toggle". $row['TEST_ID']."' name='REQUESTED_TEST[]' type='checkbox' value='" . $row['TEST_NAME'] . "'&gt;
          &lt;label for='toggle". $row['TEST_ID']."'&gt;" . $row['TEST_NAME'] . "&lt;/label&gt;
          &lt;/div&gt;
  
                      ";
                  }
              }
              else
              {
                  $output = '&lt;h3 class="text-center"&gt;'. LANG('NO_DATA_FOUND').'&lt;/h3&gt;';
              }
              echo $output;
          }
  </code></pre>