Home > Article > Web Front-end > How to Ensure Disabled Select Fields Submit with Forms?
Ensuring Disabled
To prevent user modification of a select form field's value while maintaining its presence in form submissions, using the disabled attribute may seem like the solution. However, this attribute, while preventing value changes, fails to submit the value with the form.
Consider the following alternatives:
Recommended Solution: Enabling Fields on Form Submission
To achieve the desired functionality, disable the select fields and re-enable them before form submission:
<code class="jquery">jQuery(function ($) { $('form').bind('submit', function () { $(this).find(':input').prop('disabled', false); }); });</code>
The above is the detailed content of How to Ensure Disabled Select Fields Submit with Forms?. For more information, please follow other related articles on the PHP Chinese website!