ionjack
ionjack

Reputation: 23

Disable dropdown selections based on other dropdown selections - even if selected = "selected"

I am trying to disable options in dropdowns if they have been selected in other dropdowns with jquery. The following link almost answered my question:

disable dropdown options based on the previously selected dropdown values using jquery or javascript?

But... my selections are already selected (selected = "selected") so the jquery doesn't work as it requires the user to make a selection for the code to initiate.

Is there a way to do this when your options are already selected?

Upvotes: 2

Views: 153

Answers (1)

Louys Patrice Bessette
Louys Patrice Bessette

Reputation: 33933

What about to "trigger" a change on each select on document ready ?

Just add this:

$(document).ready(function(){
    $("select.positionTypes").each(function(){
        $(this).trigger("change");
    });
});

See CodePen

Upvotes: 1

Related Questions