[英]Will a disabled text field submit when a form is POSTed?
If I submit a disabled text field via POST, what will the resulting value be on the action page? 如果我通过POST提交禁用的文本字段,结果值将在操作页面上显示什么?
For example, I have: 例如,我有:
<table border=0 cellpadding=4 cellspacing=0>
<tr><td>
<input type="checkbox" id="chk_$item"
onClick="javascript:handleClick('$item')">
</td><td>
<input type="text" id="txt_$item" name="addresses[]" value="$item">
</td></tr>
<tr><td>
...etc...
</td></tr>
</table>
the handleClick()
javascript function checks if chk_$item
is checked, if not, it disables the txt_$item
text field. handleClick()
javascript函数检查chk_$item
是否被选中,如果没有,则禁用txt_$item
文本字段。
When I submit it, all of the text fields go to an addresses[]
array in a PHP script. 当我提交它时,所有文本字段都转到PHP脚本中的
addresses[]
数组。
But, can I prevent the field from submitting anything if it is disabled? 但是,如果它被禁用,我可以阻止该字段提交任何内容吗? Will it do this by default?
它会默认执行此操作吗? If not, how should I change the behavior?
如果没有,我应该如何改变行为? (I really don't want to clear the fields when they get disabled).
(我真的不想在他们被禁用时清除这些字段)。
Disabled inputs will not be submitted with the form; 禁用的输入信息不会随表格一起提交; that's part of the defined behavior of
disabled
, cf. 这是
disabled
定义行为的一部分,参见 W3C HTML 4.01 Form docs . W3C HTML 4.01表单文档 。
如果您不想更改它,请将其readonly
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.