我正在使用PHP implode方法在我的项目上存储一些数组。现在我想在编辑时获得这些值。
检查下面的我的create.blade.php页面代码:
<div class="custom-checkbox">
<label for="receive[]">Select Receive Funds</label>
@foreach($funds as $fund)
<div class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" name="receive[]" id="{{$fund->id}}" value="{{$fund->id}}">
<label for="{{$fund->id}}" class="custom-control-label">{{$fund->title}}</label>
</div>
@endforeach
</div>
这是我的数组存储代码:
$form_data = array('receive'=>implode(',', (array)($request->receive)),)
现在,如何在单击create.blade.php的复选框上获取阵列
目前,我正在使用相同的方法进行编辑。所以我在该页面上没有任何数组值。
对于更新,我使用此代码:
$form_data = array('receive'=>implode(',', (array)($request->receive)),)
我正在使用edit.blade.php:
<label for="receive[]">Receive Funds:</label>
@foreach($funds as $fund)
<div class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" name="receive[]" id="{{$fund->id}}" value="{{$fund->id}}">
<label for="{{$fund->id}}" class="custom-control-label">{{$fund->title}}</label>
</div>
@endforeach
我如何获得这些价值?
您需要使用javascript。您可以使用jquery append。