javascript - Disabling of second dropdown depending on the value of the first dropdown in JSF -
i have dropdown id "onemenu1". jquery given below onchange event not working. unable know problem. leads appreciated.
$('#onemenu1').change(function() { if ($('#onemenu1').val() == 'never') { $('#secsdropdown').attr('disabled', true); } });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <p:selectonemenu id="onemenu1" required="true" styleclass="vehavailclass" requiredmessage="#{itrams['refreshratereq']}" editable="true" style="width:100px" value="#{dashboardaction.selectrefreshrate}"> <f:selectitem itemlabel="#{dashboardaction.vehicleavail}" itemvalue="#{dashboardaction.vehicleavail}" /> <f:selectitems value="#{dashboardaction.getrrlist()}" /> </p:selectonemenu> <!-- jira 741 start --> <p:selectonemenu id="secsdropdown" required="true" value="#{dashboardaction.unitofrefreshrate}" style="width:70px"> <f:selectitems value="#{dashboardaction.getrrunitlist()}" /> </p:selectonemenu>
you need use .prop()
method , better go class instead:
$('.vehavailclass').change(function() { $(this).next('select').prop('disabled', this.value === 'never'); }); // this.value === 'never' // results in true/false
if have select
elements in form
have notice id has been changed in manner formid:selectid
. so, in case might yourformid:onemenu1
.
updates:
$('#dashboardformid\\:onemenu1').change(function() { $('#dashboardformid\\:secsdropdown').prop('disabled', this.value === 'never'); });
here have escape :
.
Comments
Post a Comment