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

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

问题描述

我有一个复选框,在给定的条件下,需要禁用。原来,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屋!

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