I have multiple selections on my page and I have disabled the option so that the user cannot cancel them, but I cannot figure out how to get the value of the disabled option.
My code is bye
// Get selected positions var $selPositions = $('select#empPositions').val();
HTML
<select name="empPositions[]" id="empPositions" style="width: 370px;" multiple="" data-placeholder="Choose a Position" required=""> <option></option> <optgroup label="Admin"> <option disabled="">There are no positions assigned to Admin</option> </optgroup> <optgroup label="Information Technology"> <option value="1" selected="" disabled="">IT Developer</option> <option value="2">IT Geeks</option> </optgroup>
Note that the disabled option changes based on other variables, but it only gives me the selected values without disabling. Can someone tell me if this can be done and how?
I use Chosen , so the disabled parameter
Fiddle: http://jsfiddle.net/c5kn5w75/
I found this article on the jQuery Bug site that said
The long-term logic in .val () ensures that we do not return disabled options in select-multiple. This change simply applies the same behavior for select-one for consistency. You can go to the disabled option value via $ ("select"). Prop ("selectedIndex") if you need it.
But that did not work for me.
source share