javascript - how i enable disabled select n°2 after select n°1 was selected? -


i did in javascript code, not work perfectly, second "select" "disabled" default, want when selected option first "select": second "enabled" not work, enter image description here

and code :

// javascript document          var update_select = function () {      if ($("#edit-field-villes-tid").is(":selected")) {          $('#edit-field-villages-tid-option-limit').prop('disabled', false);                 }else {          $('#edit-field-villages-tid-option-limit').prop('disabled', 'disabled');      }    };    $(update_select);    $("#edit-field-villes-tid").change(update_select);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>  <form  >    <div class="views-exposed-widgets clearfix">                    <label for="edit-field-villes-tid">villes </label>         <select id="edit-field-villes-tid" name="field_villes_tid" class="form-select">       <option value="all" selected="selected">- -</option>       <option value="21">sousse</option>       <option value="22">tunis</option></select>      <label for="edit-field-villages-tid-option-limit">villages </label>  <select id="edit-field-villages-tid-option-limit" name="field_villages_tid_option_limit" class="form-select">       <option value="all" selected="selected">- -</option>       <option value="24">el zahra</option>       <option value="23">sahlool</option>        </select>                          <input class="ctools-use-ajax ctools-auto-submit-click js-hide form-submit" type="submit" id="edit-submit-tunisia" name="" value="apply">  </div></form>

someone can me ?

this worked me;

<script language='javascript' type='text/javascript'>     var update_select = function () {         if ($("#edit-field-villes-tid")[0].selectedindex > 0) {             console.log("is selected");             $('#edit-field-villages-tid-option-limit').prop('disabled', false);         } else {             console.log("is not selected");             $('#edit-field-villages-tid-option-limit').prop('disabled', true);         };     };     $(update_select);     $("#edit-field-villes-tid").on("change", update_select); </script> 

changing if check [0].selectedindex > 0 key.


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -