我有一个多选下拉列表和搜索按钮,点击搜索按钮,数据表中的所有数据都应该根据从下拉列表中选择的值进行过滤,但当我尝试过滤数据时,该表显示了我从下拉列表中选择的第一个值的记录。我不知道我做错了什么。
以下是我的html代码:
<div class="row">
<div class="col-1">
<div class="form-group">
<select name="BusinessUnit[]" id="BusinessUnit" multiple class="form-control">
@foreach($Business_unit_name as $Bu)
<option value="{{ $Bu->BusinessUnit }}" style="font-size: 5px">{{ $Bu->BusinessUnit}}</option>
@endforeach
</select>
</div>
</div>
<div class="col-1">
<div class="form-group">
<select name="CurrOrg1" id="CurrOrg1" multiple class="form-control">
@foreach($CurrOrg1_name as $org1)
<option value="{{ $org1->CurrOrg1 }}">{{ $org1->CurrOrg1 }}</option>
@endforeach
</select>
</div>
</div>
<div class="col-1">
<div class="form-group">
<select name="CurrOrg2" id="CurrOrg2" multiple class="form-control">
@foreach($CurrOrg2_name as $org2)
<option value="{{ $org2->CurrOrg2 }}">{{ $org2->CurrOrg2 }}</option>
@endforeach
</select>
</div>
</div>
<div class="col-1">
<div class="form-group">
<select name="CurrOrg3" id="CurrOrg3" multiple class="form-control">
@foreach($CurrOrg3_name as $org3)
<option value="{{ $org3->CurrOrg3 }}">{{ $org3->CurrOrg3 }}</option>
@endforeach
</select>
</div>
</div>
<div class="col-1">
<div class="form-group">
<select name="CurrOrg4" id="CurrOrg4" multiple class="form-control">
@foreach($CurrOrg4_name as $org4)
<option value="{{ $org4->CurrOrg4 }}">{{ $org4->CurrOrg4 }}</option>
@endforeach
</select>
</div>
</div>
<div class="col-1">
<div class="form-group">
<select name="CurrOrg5" id="CurrOrg5" multiple class="form-control">
@foreach($CurrOrg5_name as $org5)
<option value="{{ $org5->CurrOrg5 }}">{{ $org5->CurrOrg5 }}</option>
@endforeach
</select>
</div>
</div>
<div class="col-1">
<div class="form-group">
<select name="ProfessionalClassification" id="ProfessionalClassification" multiple class="form-control">
@foreach($ProfessionalClassification_name as $pro)
<option value="{{ $pro-> ProfessionalClassification }}">{{ $pro->ProfessionalClassification }}</option>
@endforeach
</select>
</div>
</div>
<div class="col-1">
<div class="form-group">
<select name="Role" id="Role" multiple class="form-control">
@foreach($Role_name as $Role)
<option value="{{ $Role->Role }}">{{ $Role->Role }}</option>
@endforeach
</select>
</div>
</div>
<div class="col-1">
<div class="form-group">
<select name="Region" id="Region" multiple class="form-control">
@foreach($Region_name as $Region)
<option value="{{ $Region->Region }}">{{ $Region->Region }}</option>
@endforeach
</select>
</div>
</div>
<div class="col-1">
<div class="form-group">
<select name="Gender" id="Gender" multiple class="form-control">
@foreach($Gender_name as $Gender)
<option value="{{ $Gender->Gender }}">{{ $Gender->Gender }}</option>
@endforeach
</select>
</div>
</div>
<div class="col-1">
<div class="form-group">
<button class="btn btn-primary rounded" type="button" id="search" name="search" style="background-color: #CA0088;width: 70px">Apply</button>
</div>
</div>
<div class="col-1">
<div class="form-group">
<button class="btn btn-primary rounded" type="button" id="reset" name="reset" style="background-color: #D5665F;width: 70px">Reset</button>
</div>
</div>
这是我的剧本:
$('#search').click(function(){
var BusinessUnit = $('#BusinessUnit').val();
var Role = $('#Role').val();
var CurrOrg1 = $('#CurrOrg1').val();
var CurrOrg2 = $('#CurrOrg2').val();
var CurrOrg3 = $('#CurrOrg3').val();
var CurrOrg4 = $('#CurrOrg4').val();
var CurrOrg5 = $('#CurrOrg5').val();
var Region = $('#Region').val();
var ProfessionalClassification = $('#ProfessionalClassification').val();
var Gender = $('#Gender').val();
if(BusinessUnit != '' || CurrOrg1 != '' || CurrOrg2 != '' || Role != '' || Region != '' || Gender != '' || CurrOrg3 != '' || CurrOrg4 != '' || CurrOrg5 != '' || ProfessionalClassification != '') {
$('#members_data').DataTable().destroy();
fill_datatable(BusinessUnit,CurrOrg1,CurrOrg2,Role,Region,Gender,ProfessionalClassification,CurrOrg3,CurrOrg4,CurrOrg5);
} else {
alert('Select filter option');
}
});
不确定我在这里做错了什么,是否有其他方法传递多个值?
暂无答案!
目前还没有任何答案,快来回答吧!