javascript - Disable certain selected option for its counterpart from dropdown -


i have 2 dropdowns. when select option one, want option five disabled second dropdown.

how can achieve that. below dropdown code.

<form>   <select class="myselect">     <option>one</option>     <option>two</option>     <option>three</option>   </select> </form>  <br>  <form>   <select class="myselect">     <option>four</option>     <option>five</option>     <option>six</option>   </select> </form> 

here's fiddle that.

first of 1 thing should notice cannot use same ids multiple elements in 1 single page. id has unique each element.

in case can change class:

$('.myselect:eq(0)').change(function(){    $('option:contains(five)').prop('disabled', this.value == "one");  }).change(); // <---this makes sure fire change event on doc ready               // because have option value "one" selected.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <form>    <select class="myselect">      <option>one</option>      <option>two</option>      <option>three</option>    </select>  </form>    <br>    <form>    <select class="myselect">      <option>four</option>      <option>five</option>      <option>six</option>    </select>  </form>


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -