am making filter system with multi select or check box the user can check box1 and search with it and the the user check box2 now it should search with box 1 and box2
the way I've decided to make it is when the user clicks on box1 it send get request with ajax that holds the row name that the user want to search in and the id (value) and use the selector and the id to search in the db table and return result to the user, then when the user check box2 it also save the selector and the id of box2 in a session, I want to use the session key in this case its the table row and the session value the id, to search for both box1 and box2,
here is part of my code hope it will make it more clear
$(document).ready(function(){
$(".genral").click(function(){
$("#overlay").fadeIn(300);
var elmId = $(this).attr("id");
var livesearchVal = $("#livesearch").val();
var types = $(this).attr("data-type");
var selector = $(this).attr("data-uniqe");
console.log(url + 'hey');
$.ajax({
type: 'GET',
url: "/ajax/genaral_specializations2.php?id="+elmId+'&term='+livesearchVal+'&types='+types+'&selector='+selector,
success: function(data){
$("#paginate_books").html(data);
$("#overlay").fadeOut(300);
}
});
});
});
var elmid = the value of the checkbox,
var term = it's the search term that user entered in the input text (not important)
var types = (not important)
var selector = the table row name for example (table cast row name),
below is part of the controller controller
$gen_spci_no = $_GET['id'];
$table_uniqe = $_GET['selector'];
session()->put($table_uniqe, $gen_spci_no);
$input = collect($filter_sessions)->filter(function($value) {
return null !== $value;
})->toArray();
like you see above I put the new session box2 alongside box1 I already know all the session names so am gonna loop throw them and get the once that already been set and assign them to the $input array this array should hold the session key and name like this
$input = array($sessionkey => $sessionval);