问题描述
@extends('layouts.app')
@section('content')
<body>
<button class="btn" onclick="deleteSelected()">delete</button>
<table class="table">
<thead>
<tr>
<th scope="col">
<input type="checkBox" id="all" onclick="chkd()">
</th>
<th scope="col">id</th>
<th scope="col">title</th>
<th scope="col">Paragraph</th>
</tr>
</thead>
@foreach ($categories as $categorie)
<tbody>
<tr>
<td>
<input type="checkBox" class="ss" value="{{ $categorie->id }}" onclick="deleteSelected()">
</td>
<th scope="row">{{ $categorie->id }}</th>
<td>{{ $categorie->Title }}</td>
<td>{{ $categorie->Paragraph }}</td>
<form action={{ route('categorie.destroy',$categorie->id) }} method="POST">
@csrf
@method('DELETE')
<td>
<button id="deleteRow" class="btn btn-danger" type="submit" style="display: none">
delete
</button>
</form>
<button class="btn btn-warning"> <a href={{ route('edit',$categorie->id) }}>edit</a> </button>
</td>
</tr>
</tbody>
@endforeach
</table>
</body>
@endsection
这就是我的观点,当我选中一个复选框并按下按钮删除时,我希望删除该行,或者当我选中所有我想删除所有行时
解决方法
我认为 html input 必须在 form 内。像这样移动代码怎么样:
@foreach ($categories as $categorie)
<tbody>
<tr>
<td>
<form action={{ route('categorie.destroy',$categorie->id) }} method="POST">
@csrf
@method('DELETE')
<input type="checkbox" class="ss" value="{{ $categorie->id }}" onclick="deleteSelected()">
<button id="deleteRow" class="btn btn-danger" type="submit" style="display: none">
delete
</button>
</form>
</td>
<th scope="row">{{ $categorie->id }}</th>
<td>{{ $categorie->Title }}</td>
<td>{{ $categorie->Paragraph }}</td>
<td><button class="btn btn-warning"> <a href={{ route('edit',$categorie->id) }}>edit</a> </button></td>
</tr>
</tbody>
@endforeach
但是,我不知道这是否可以解决您的问题。我看不到整个代码