I have the next checkbox:
<input type="checkbox" value="true" name="permanentEmployee" checked="" id="permanentEmployee" disabled="">
I've set the attribute disabled
to true and submitted the form
$("#permanentEmployee").prop('disabled', true);`
On server side, if I do:
request.getParameter("permanentEmployee")
I get the value as Null , though I get the the correct value (ie True ) if I don't disable the checkbox. Why am I not getting the disabled checkbox value as True even if it is checked?
Disabled form elements are not sent via form submit.
You can consider using read-only instead
One idea would be
$('#permanentEmployee').click(function(){
return false; // even if the user clicks on it it will not change
});
$('#permanentEmployee').prop('checked', true);
在提交表单(提交提交侦听器)之前,您可以启用该复选框。
Disabled check boxes (and probably other form elements) are not sent to the server.
There are a couple of solutions here: How to ensure a <select> form field is submitted when it is disabled?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.