When I'm disabling a
<select name="sel" disabled>
<option>123</option>
</select>
element, it doesnt pass its variable.
What to do to look it like disabled, but be in "normal" state?
This is because I have a list of "selects", and sometimes some of them have single value, so user should understand that it has only one value without clicking it.
You can keep it disabled as desired, and then remove the disabled attribute before the form is submitted.
Note that if you rely on this method, you'll want to disable it programmatically as well, because if JS is disabled or not supported, you'll be stuck with the disabled select.
Add a class
.disabled
and use this CSS:Demo: http://jsfiddle.net/ZCSRq/
If you can supply a default value for your selects, then you can use the same approach for unchecked check boxes which requires a hidden input before the actual element, as these don't post a value if left unchecked:
This will actually post the value "default" (without quotes, obviously) if the select is disabled by javascript (or jQuery) or even if your code writes the html disabling the element itself with the attribute: disabled="disabled".
One could use an additional hidden input element with the same name and value as that of the disabled list. This will ensure that the value is passed in $_POST variables.
Eg:
or you can use jQuery
if you don't want add the attr disabled can do it programmatically
can disable the edition into the
<select class="yourClass">
element with this code:if you want try it can see it here: https://jsfiddle.net/9kjqjLyq/