Laravel 如何从数据库中获取数据并显示在选择器中?
How to get data from database and show it in selectpicker in Laravel?
我有一个表单页面和详细信息页面。当我从表单页面输入和提交数据时,它将重定向到详细信息页面。而且我不知道如何显示我提交到选择器中的数据?它显示了,但像下图一样..
<select id="set1" name="res_destination" class="selectpicker form-control edit" data-live-search="true" style="width:100%" disabled required>
<option>{{ $data[0]->DESTINATION }}</option>
<option></option>
@foreach($destination as $getData)
<option value="{{$getData->REF_TEXT}}"> {{$getData->REF_TEXT}} </option>
@endforeach
</select>
使用 selected
选择下拉值。
<select id="set1" name="res_destination" class="selectpicker form-control edit" data-live-search="true" style="width:100%" disabled required>
@foreach($destination as $getData)
<option value="{{$getData->REF_TEXT}}" @if($data[0]->DESTINATION==$getData->REF_TEXT) selected @endif> {{$getData->REF_TEXT}} </option>
@endforeach
我有一个表单页面和详细信息页面。当我从表单页面输入和提交数据时,它将重定向到详细信息页面。而且我不知道如何显示我提交到选择器中的数据?它显示了,但像下图一样..
<select id="set1" name="res_destination" class="selectpicker form-control edit" data-live-search="true" style="width:100%" disabled required>
<option>{{ $data[0]->DESTINATION }}</option>
<option></option>
@foreach($destination as $getData)
<option value="{{$getData->REF_TEXT}}"> {{$getData->REF_TEXT}} </option>
@endforeach
</select>
使用 selected
选择下拉值。
<select id="set1" name="res_destination" class="selectpicker form-control edit" data-live-search="true" style="width:100%" disabled required>
@foreach($destination as $getData)
<option value="{{$getData->REF_TEXT}}" @if($data[0]->DESTINATION==$getData->REF_TEXT) selected @endif> {{$getData->REF_TEXT}} </option>
@endforeach