sim bryan
sim bryan

Reputation: 1

JQuery, How to diasable dropdownlists value when other dropdownlist value that selected

I wrote a script that can add dropdownlist with button, and every dropdownlists can't select the same value from database.

$(document).ready(function(){  
  $("select").change(function() {   
    $("select").not(this).find("option[value="+ $(this).val() + "]").attr('disabled', true);
  }); 
}); 

But still it is not working.

Upvotes: 0

Views: 30

Answers (1)

Svela
Svela

Reputation: 639

$("select").not(this).find("option[value="+ $(this).val() + "]").attr('disabled', true);

..should be:

$("select").not(this).find("option[value='"+ $(this).val() + "']").prop('disabled', true);

Upvotes: 1

Related Questions