残疾人表单输入不会出现在请求 [英] Disabled form inputs do not appear in the request
本文介绍了残疾人表单输入不会出现在请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个表格一些残疾人的投入,我想将它们发送到服务器,而Chrome不包括他们的请求。
有没有办法解决这个不添加隐藏字段?
<形式的行动=/媒体/添加>
<输入类型=隐藏的名字=ID值=123/> <! - 这不会出现在请求 - >
<输入类型=文本名称=百分比值=100禁用=禁用/>< /表及GT;
解决方案
有残疾属性的元素都没有提交,也可以说他们的值不会公布。
即
<输入类型=文本名称=百分比值=100禁用=禁用/>
仅供参考,
- 禁用控件不接收焦点。
- 禁用的控件被跳过Tab切换导航。
- 禁用的控件无法成功发布。
您可以在您的情况使用只读属性,这样做,你将能够张贴您的字段的数据。
即
<输入类型=文本名称=百分比值=100只读=只读/>
仅供参考,
- 只读元素接收焦点但不能被用户修改。
- 只读的元素都包括在跳格导航。
- 只读元素被成功发布。
希望这有助于。
I have some disabled inputs in a form and I want to send them to a server, but Chrome excludes them from the request.
Is there any workaround for this without adding a hidden field?
<form action="/Media/Add">
<input type="hidden" name="Id" value="123" />
<!-- this does not appear in request -->
<input type="textbox" name="Percentage" value="100" disabled="disabled" />
</form>
解决方案
Elements with Disabled attribute are not submitted or you can say their values are not posted.
i.e.
<input type="textbox" name="Percentage" value="100" disabled="disabled" />
FYI,
- Disabled controls do not receive focus.
- Disabled controls are skipped in tabbing navigation.
- Disabled controls cannot be successfully posted.
You can use readonly attribute in your case, by doing this you will be able to post your field's data.
i.e.
<input type="textbox" name="Percentage" value="100" readonly="readonly" />
FYI,
- Read-only elements receive focus but cannot be modified by the user.
- Read-only elements are included in tabbing navigation.
- Read-only elements are successfully posted.
Hope this helps.
这篇关于残疾人表单输入不会出现在请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文