I have a select
form field that I want to mark as "readonly", as in the user cannot modify the value, but the value is still submitted with the form. Using the disabled
attribute prevents the user from changing the value, but does not submit the value with the form.
The readonly
attribute is only available for input
and textarea
fields, but that's basically what I want. Is there any way to get that working?
Two possibilities I'm considering include:
select
, disable all of the option
s and use CSS to gray out the select so it looks like its disabled.Disable the fields and then enable them before the form is submitted:
jQuery code:
jQuery(function ($) {
$('form').bind('submit', function () {
$(this).find(':input').prop('disabled', false);
});
});