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).
但是,如果禁用该字段,我可以阻止该字段提交吗?它会默认执行此操作吗?如果没有,我应该如何改变行为? (我真的不想在他们被禁用时清除这些字段)。
2 个解决方案
#1
57
Disabled inputs will not be submitted with the form; that's part of the defined behavior of disabled
, cf. W3C HTML 4.01 Form docs.
禁用的输入信息不会随表格一起提交;这是残疾人定义行为的一部分,参见W3C HTML 4.01表单文档。
#2
21
If you don't want it changed, make it readonly
.
如果您不想更改,请将其设为只读。
#1
57
Disabled inputs will not be submitted with the form; that's part of the defined behavior of disabled
, cf. W3C HTML 4.01 Form docs.
禁用的输入信息不会随表格一起提交;这是残疾人定义行为的一部分,参见W3C HTML 4.01表单文档。
#2
21
If you don't want it changed, make it readonly
.
如果您不想更改,请将其设为只读。