javascript - Disable other options in a dropdown, if clicked on the first option -


i have dropdown can select multiple options. if select 1 option in that, need rest of options disabled.

for example : in below code, if select option all, need rest of options disabled.

<select id="searchregion" name="searchregion" multiple="multiple"> <option> choose region(s) </option> <option value="all"> </option> <option value="east"> east </option> <option value="north"> north </option> <option value="west"> west </option> <option value="south"> south </option> </select> 

image

try

var $searchregion = $('#searchregion').change(function() {    var isall = $searchregion.find('[value="all"]').is(':selected');    if (isall) {      $searchregion.val('all');    }    $searchregion.find('option').not('[value="all"]').prop('disabled', isall);  })
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>  <select id="searchregion" name="searchregion" multiple="multiple">    <option>choose region(s)</option>    <option value="all">all</option>    <option value="east">east</option>    <option value="north">north</option>    <option value="west">west</option>    <option value="south">south</option>  </select>


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -