如何发布/提交禁用的输入复选框? [英] how to POST/Submit an Input Checkbox that is disabled?

查看:15
本文介绍了如何发布/提交禁用的输入复选框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个复选框,在特定条件下,需要禁用该复选框.结果证明 HTTP 不会发布禁用的输入.

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 不适用于复选框

您可以使用 disabled="disabled" 但此时复选框的值不会出现在 POST 值中.其中一种策略是在同一表单中添加一个包含复选框值的隐藏字段,然后从该字段读取值

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

只需将 disabled 更改为 readonly

这篇关于如何发布/提交禁用的输入复选框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆