0
所以我試圖創建一個循環遍歷$個國家的下拉菜單,然後將所選國家寫入數據庫中用戶表下的$ country。我得到了下拉菜單,但是它向數據庫返回一個空值(至少是驗證)。<select>標記向數據庫返回一個空值
這裏是呼籲下拉
<div class="form-group col-lg-6 col-sm-12">
<label for="country">Country</label>
<div id="countrydd">
@if(isset($currentCountry->name))
<select name="country" id="country_display" class="current-value-da-select closed">
{{(isset($user->country->name))?$user->country->name:$currentCountry->name}}
@foreach($countries as $country)
<option value="{{$country->name}}">{{$country->name}}</option>
@endforeach
</select>
@else
<select name="country" id="country_display" class="current-value-da-select closed">
{{(isset($user->country->name))?$user->country->name:'Select your Country'}}
@foreach($countries as $country)
<option value="{{$country->name}}">{{$country->name}}</option>
@endforeach
</select>
@endif
這是JavaScript的下拉
//Country Drop Down
$('#countrydd').click(function(e) {
var selectWrapperCountry = $('#countrydd');
var currentValueCountry = $(this).find('a').html();
selectWrapperCountry.find('.current-value-da-select').html(currentValueCountry);
selectWrapperCountry.find('#country').val(currentValueCountry);
updateCarretClassCountry();
});
$('#countrydd a.current-value-da-select').click(function() {
updateCarretClassCountry();
});
function updateCarretClassCountry(){
if($('#countrydd a.current-value-da-select').hasClass('closed')) {
$('#countrydd a.current-value-da-select').attr('class', 'current-value-da-select opened');
}
else
{
$('#countrydd a.current-value-da-select').attr('class', 'current-value-da-select closed');
}
};
任何幫助來獲得更新的權利將是真棒值。
另外''
' – Archer
@DanFromGermany done –