I need to disable options with value "- Sold Out -" in a list of dynamic drop down menus. How can I do this easily with jQuery? Below is the HTML
<select id="field_0_1" class="text_select" name="field_0_1" onChange="">
<option value="">- Preferred Time -</option>
<option value="- Sold Out -">- Sold Out -</option>
<option value="2:30 - 4:00pm">2:30 - 4:00pm</option>
</select>
<select id="field_0_2" class="text_select" name="field_0_2" onChange="">
<option value="">- Preferred Time -</option>
<option value="- Sold Out -">- Sold Out -</option>
<option value="2:30 - 4:00pm">2:30 - 4:00pm</option>
</select>
<select id="field_0_3" class="text_select" name="field_0_3" onChange="">
<option value="">- Preferred Time -</option>
<option value="- Sold Out -">- Sold Out -</option>
<option value="2:30 - 4:00pm">2:30 - 4:00pm</option>
</select>
To disable auto-completion of input fields, use the HTML attribute autocomplete with a value set to off .
multiselect('disable'); will disable the selector (stored in the variable $widget ). And by replacing disable with enable you can enable it. So just run the function with the correct disable/enable setting and you can do it based on any condition.
$("select option[value*='Sold Out']").prop('disabled',true);
Demo
$('#previous_select').on('change', function() {
// after creating the option
// try following
$("select option[value*='Sold Out']").prop('disabled',true);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With