Searching over the google and stack overflow, could not find a solution to this.
I have two dropdown in MVC core view
dropdown a looks like following:
<option>A</option>
<option>B</option>
and second dropdown looks like following:
<option>A1</option>
<option>A2</option>
<option>A3</option>
<option>B1</option>
<option>B2</option>
I need to disable A1,A2,and A3 in second dropdown when B is selected in the first dropdown and disable B1, and B2 when A is selected in the first dropdown.
I tried the following but it is not working:
$('#FirstDropDown').change(function () {
var data = $(this).val();
if (data == "A") {
$("#SecondDropDown option[value='A1']").attr('disabled', 'disabled');
$("#SecondDropDown option[value='A2']").attr('disabled', 'disabled');
$("#SecondDropDown option[value='A3']").attr('disabled', 'disabled');
}
});