Hi I need to delete multiple user records, selected by multiple check boxes and then press delete and submit the form userListform
.
deleteUser()
<a href="javascript:void();" class="btn btn-outline-danger" onclick="deleteUser();">Delete</a>
<form method="POST" action="{{url('/user/delete')}}" id="userListform" >
Route::post('/user/delete', 'UsersController@delete');
function deleteUser(){
var $checkboxes = jQuery('#userListform input[type="checkbox"]');
checkedItems = $checkboxes.filter(':checked').length;
if(checkedItems > 0){
var status = confirm("Do you need to delete the user!!");
if (status == true) {
document.getElementById("userListform").submit();
} else {
return false;
}
}else{
alert("Please select the users to be deleted!");
}
}
I have successfully submited the form but i'm not getting to the delete function of the usercontroller@delete
method , instead it is showing 404 error
在表单中添加csrf令牌,它将起作用
You can try this
in the view
<form method="POST" action="{{route('user.delete')}}" id="userListform" >
in the route
Route::post('/user/delete', 'UsersController@delete')->name('user.delete);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.