Sohil Shingala
Sohil Shingala

Reputation: 204

Disable specific "selectize" dropdown option

I am trying to disable shipping location in selectize drop down for already selected for same code. for example in the screenshot you can see code "Apple" first time shippping locatin i have already selected "Mumbai" now i try to add code "Apple" second time now in the shipping location "Mumbai" should be disabled but "Surat" only enable to select.

enter image description here

Upvotes: 1

Views: 2191

Answers (1)

Uttam Gupta
Uttam Gupta

Reputation: 518

Please refer below code

<script type="text/javascript">
    $(document).ready(function () {
        $('#fruit').change(function () {
            if ($(this).val() == "1") {
                $('#Location').find('option[value=1]').attr("disabled", true);
            }
        });
    });

</script>

//html

<select id="fruit">
    <option>select</option>
    <option value="1">Apple</option>
    <option value="2">Cherry</option>
</select>

<select id="Location">
    <option>select</option>
    <option value="1">Mumbai</option>
    <option value="2">Delhi</option>
</select>

Upvotes: 2

Related Questions