- How to create a Javascript function to save the selected checkbox into database when I click the Submit function?
In the laravel controller I know how to save it.
I just want to know how is the function to pass the data from the view to javascript?
``
<div class="table-responsive">
<button style="margin-bottom: 10px" class="btn btn-primary submitDatabase" data-url="">Submit to database</button>
<table class="table table-hover">
<thead>
<tr>
<th width="50px"><input type="checkbox" id="checkBox"></th>
<th>ID</th>
<th>Approved Date</th>
<th>Name</th>
<th>NRIC</th>
<th>Hospital</th>
<th>Condition</th>
<th>Cancer Type</th>
<th>Action</th>
</tr>
</thead>
<tbody>
@foreach($datas as $item)
<tr>
<td><input type="checkbox" class="singleSelectBox" data-id="{{$item->id}}"></td>
<td>{{$item->id}}</td>
<td>{{date('d-m-Y',strtotime($item->dtDecidedOn))}}</td>
<td>{{$item->varNm}}</td>
<td>{{$item->varIdNumber}}</td>
<td>{{$item->varHospitalNm}}</td>
<td>{{$item->varPrognosesNm}}</td>
<td>{{$item->varCancerNm}}</td>
<td><button class="btn btn-primary btn-sm reprint" id="{{$item->id}}" value="#">View</button></td>
</tr>
</tbody>
@endforeach
</table>
</div>
I expect that if select all, all the data that has been selected will be saved in the database.
if single row data is selected, the data will be saved in the database.