我有下一个复选框:
<input type="checkbox" value="true" name="permanentEmployee" checked="" id="permanentEmployee" disabled="">
我已将属性 disabled
设置为 true 并提交了表单
$("#permanentEmployee").prop('disabled', true);`
在服务器端,如果我这样做:
request.getParameter("permanentEmployee")
我得到的值为Null,但如果我不禁用该复选框,我会得到正确的值(即True)。即使已选中,为什么我没有将禁用的复选框值设置为 True?
最佳答案
禁用的表单元素不会通过表单提交发送。 您可以考虑使用只读代替
一个想法是
$('#permanentEmployee').click(function(){
return false; // even if the user clicks on it it will not change
});
$('#permanentEmployee').prop('checked', true);
关于javascript - 如何将禁用的元素值发送到服务器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25060499/