I have a problem with a checkbox: when doing a LIVEsearch, the value of the checkbox is always set to 1/true. When i do the same thing in a normal search (without the js file) i dont have this problem. First of all the code of my checkbox:
Than the Code of my javascript (i guess the problem is to get the value of the checkbox)
<script>
$(document).ready(function(){
$(".search").keyup(function(){
var staffid= $("#search-staffid").val();
var firstName= $("#search-first-name").val();
var lastName= $("#search-last-name").val();
var birthday= $("#search-birthday").val();
var children= $("#search-children").val();
var deleted= $("#search-deleted").val();
if(staffid == "" && firstName == "" && lastName == "" && birthday == "" && children == "" ) {
$( "#liveResult" ).html("<b>Suchergebnisse werden hier angezeigt</b>");
}else {
$.get( "" +
'?staffid=' + staffid +
'&first_name=' + firstName +
'&last_name=' + lastName +
'&birthday=' + birthday +
'&children=' + children +
'&deleted=' + deleted
, function( data ) {
$( "#liveResult" ).html( data );
});
}
});
});
</script>
As you see i have some other fields, they work without any problems. Finally the Code of my controller:
public function liveSearch(Request $request)
{
$data = [
'id' => $request->staffid,
'first_name' => $request->first_name,
'last_name' => $request->last_name,
// converts date format only if birthday != null
'birthday' => ($request->birthday ? date('Y-m-d', strtotime($request->birthday)) : null),
'children' => $request->children,
'deleted' => $request->deleted
];
if (is_null($data['id']) && is_null($data['first_name']) && is_null($data['last_name']) && is_null($data['birthday']) && is_null($data['children']))
{
return view('staff.livesearch');
}
else
{
dd ($data['deleted']);
}
}
Aucun commentaire:
Enregistrer un commentaire