如何POST /提交禁用的输入复选框? [英] how to POST/Submit an Input Checkbox that is disabled?
问题描述
我有一个复选框,在给定的条件下,需要禁用。原来,HTTP不会发布禁用的输入。
我该如何解决这个问题?提交输入,即使它被禁用并保持输入被禁用? $ c> READONLY 在复选框上不起作用
您可以使用 disabled =disabled
,但此时复选框的值不会显示在 POST
值中。其中一种策略是在同一表单中添加一个隐藏字段,并在该表单中添加复选框的值,并从该字段中读取值
只需更改 禁用
为只读
I have a checkbox that, given certain conditions, needs to be disabled. Turns out HTTP doesn't post disabled inputs.
How can I get around that? submitting the input even if it's disabled and keeping the input disabled?
UPDATE: READONLY
doesn't work on checkboxes
You could use disabled="disabled"
but at this point checkbox's value will not appear into POST
values. One of the strategy is to add an hidden field holding checkbox's value within the same form and read value back from that field
Simply change disabled
to readonly
这篇关于如何POST /提交禁用的输入复选框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!