如何使用Javascript和jquery使用radiobutton启用或禁用引导选择下拉列表
我有两个单选按钮和一个引导选择下拉菜单。我想在两个单选按钮的帮助下使用javascript启用/禁用下拉菜单 我的Html代码如下所示:如何使用Javascript和jquery使用radiobutton启用或禁用引导选择下拉列表,javascript,html,jquery,Javascript,Html,Jquery,我有两个单选按钮和一个引导选择下拉菜单。我想在两个单选按钮的帮助下使用javascript启用/禁用下拉菜单 我的Html代码如下所示: <div class="container" style="margin-top: 5px;background-color: wheat;"> <div class="card" style="background-color: white;margin: 1em&qu
<div class="container" style="margin-top: 5px;background-color: wheat;">
<div class="card" style="background-color: white;margin: 1em">
<!--<div class="card-header"></div>-->
<div class="card-body">
<div class="row">
<div class="col-lg-2">
<label style="margin-top: 1.2em;margin-left: 1em">Type</label>
</div>
<div class="row" >
<div class="col-sm-1">
<div class="form-check" style="margin-top: 1.1em;margin-left: 1em">
<label class="form-check-label">
<input type="radio" class="form-check-input" name="rbType" id="typeNew" value="enable" >New
</label>
</div>
</div>
<div class="col-sm-2">
<div class="form-check" style="margin-top: 1.1em;margin-left: 1em">
<label class="form-check-label">
<input type="radio" class="form-check-input" name="rbType" id="typeVisisting" value="disable">Visiting
</label>
</div>
</div>
</div>
</div>
<div class="row" >
<div class="col-lg-2">
<label style="margin-top: 1.2em;margin-left: 1em" for="selectCustomer" >Customer Name</label>
</div>
<div class="col-lg-10">
<div class="form-group" style="margin-top: .5em;margin-right: 1em">
<select class=" form-control input-lg" data-live-search="true" title="-- Select a Customer --" name="selectCustomer" id="selectCustomer" >
<!--<option value="none">-- Select a Customer --</option>-->
@foreach($customers as $customer)
<option value="{{$customer->customer_id}}">{{$customer->customer_id}} {{$customer->customer_name}}</option>
@endforeach
</select>
</div>
</div>
</div>
</div>
</div>
类型
新的
参观
客户名称
@foreach($customers作为$customer)
{{$customer->customer\u id}{{{$customer->customer\u name}
@endforeach
请帮我解决这个问题。我在这方面工作了三天。在下面添加jquery
$('input[name="rbType"]').change(function(){
if(this.value == "enable"){
$('#selectCustomer').removeAttr('disabled')
}
if(this.value == "disable"){
$('#selectCustomer').attr('disabled','true')
}
})
使用jquery在javascript标记中尝试此操作
$('input[name="rbType"]').change(function(){
if(this.value == "enable"){
$('#selectCustomer').prop('disabled',false)
}
if(this.value == "disable"){
$('#selectCustomer').prop('disabled','true')
}
})