如何使输入字段只读,但仍将其发送回表单的数据? [英] How can I make an input field read only but still have it send data back to a form?
本文介绍了如何使输入字段只读,但仍将其发送回表单的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个输入字段:
<input cid="Topic_Created" name="Topic.Created" size="25" type="text" value="6/5/2011 8:22:45 AM" />
我想让字段显示在我的表单上,但不希望用户能够编辑场。当用户单击提交时,我想将表单值发送回服务器。
I want the field to display on my form but don't want the user to be able to edit the field. When the user clicks submit I want the form value to be sent back to the server.
这是可能的。我尝试了 disabled =disabled
, readonly =readonly
的不同组合。似乎我总是没有收到任何回传的字段。
Is this possible. I tried different combinations of disabled = "disabled"
, readonly = "readonly"
. Seems I always get nothing sent back for the field.
推荐答案
添加一个具有相同名称的隐藏字段将发送数据表单提交。
Adding a hidden field with the same name will sends the data when the form is submitted.
<input type="hidden" name="my_name" value="blablabla" />
<input type="text" name="my_name" value="blablabla" disabled="disabled" />
这篇关于如何使输入字段只读,但仍将其发送回表单的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文