【问题标题】:How can I make a textbox readonly in this code [duplicate]如何在此代码中使文本框只读[重复]
【发布时间】:2015-02-21 10:33:18
【问题描述】:
<label class="control-label" for="inputEmail">First Name:</label>
<div class="controls">
<input type="text" class="span4" id="inputEmail" name="firstname"  value="<?php echo $row['firstname']; ?>" placeholder="First Name" required>
<input type="hidden" id="inputEmail" name="id" value="<?php echo $get_id;  ?>" placeholder="First Name" required>     

【问题讨论】:

  • 你想让什么只读? #inputEmail?
  • 这里的问题是什么?如何使输入字段/ textarea 只读是有据可查的。您只需查看文档即可获得答案。
  • 这个问题有点Already answered

标签: php html forms


【解决方案1】:

如果您想让文本字段只读,请使用 readonly 属性。

一个例子:

<input type="text"value="foo"readonly>

来自您的代码

<label class="control-label" for="inputEmail">First Name:</label>
<div class="controls">
<input type="text" class="span4" id="inputEmail" name="firstname"  value="<?php echo $row['firstname']; ?>" placeholder="First Name"readonly>
<input type="hidden" id="inputEmail" name="id" value="<?php echo $get_id;  ?>" placeholder="First Name" readonly>     

【讨论】:

  • 好的。谢谢。它有效。
  • @jeanko 不客气!
【解决方案2】:

如果你想让 inputEmail 成为只读字段,你可以使用

<label class="control-label" for="inputEmail">First Name:</label>
<div class="controls">
<input type="text" class="span4" id="inputEmail" name="firstname"  value="<?php echo $row['firstname']; ?>" placeholder="First Name" required readonly>
<input type="hidden" id="inputEmail" name="id" value="<?php echo $get_id;  ?>" placeholder="First Name" required>  

请注意,我在第 3 行的输入标记末尾添加了只读。

【讨论】:

  • 没问题。您可以通过选择其中一个答案并用“勾号”标记它来结束问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-07-30
  • 1970-01-01
  • 1970-01-01
  • 2015-04-19
  • 1970-01-01
  • 1970-01-01
  • 2020-07-02
相关资源
最近更新 更多