php 使文本框不可见或只读

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14706194/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 07:50:00  来源:igfitidea点击:

Making a Textbox invisible or read only

phpjqueryhtmlmysqlcss

提问by Kelvin Bala

<html>
<body>
  <form action="MyInserts.php" method="GET">
    <a href="http://localhost/login.htm" target="_blank">CLICK HERE TO LOGIN</a>
    <br>
    <p><u>Create Acct</u></p>
    <br>
    firstname: <input type="text" name="firstbox"><br>
    lastname:  <input type="text" name="lastbox"><br>
    id number:  <input type="text" name="idbox"><br>

    <input type="submit" value="Create">
  </form>
</html>

回答by iLaYa ツ

Readonly:

只读:

<INPUT TYPE="text" NAME="firstbox" readonly="readonly">

Disable:

禁用:

<INPUT TYPE="text" NAME="firstbox" disabled="disabled">

Invisible:

无形的:

<INPUT TYPE="text" NAME="firstbox" type="hidden">

UPDATE

更新

READONLY and DISABLED both remove the functionality of the input field, but to different degrees. READONLY locks the field: the user cannot change the value. DISABLED does the same thing but takes it further: the user cannot use the field in any way, not to highlight the text for copying, not to select the checkbox, not to submit the form. In fact, a disabled field is not even sent if the form is submitted.

READONLY 和 DISABLED 都删除了输入字段的功能,但程度不同。READONLY 锁定字段:用户不能更改值。DISABLED 做同样的事情,但更进一步:用户不能以任何方式使用该字段,不能突出显示要复制的文本,不能选中复选框,不能提交表单。事实上,即使提交了表单,也不会发送禁用字段。

回答by Guerra

Readonly :

只读 :

<INPUT TYPE="text" NAME="firstbox" readonly>

Invisible

无形的

<INPUT TYPE="text" NAME="firstbox" style="display: none">

回答by Vinoth Babu

Use readonly in that attribute of textbox tag,

在 textbox 标签的那个属性中使用 readonly,

<INPUT TYPE="text" NAME="firstbox" readonly>

回答by Sowmya

Add readonly="readonly"

添加 readonly="readonly"

<INPUT TYPE="text" NAME="firstbox" readonly="readonly">

DEMO

演示

回答by Morpheus

Use CSS:

使用 CSS:

input[name=firstbox]
{
   display: none;
}

or change html:

或更改 html:

<INPUT TYPE="text" NAME="firstbox" readonly>

回答by Enve

You can use disabled="disabled"example

您可以使用disabled="disabled"示例

<input type="text" name="firstbox" disabled="disabled" />

or readonly="readonly"

或者 readonly="readonly"

<input type="text" name="firstbox" readonly="readonly" />

DEMO: http://jsfiddle.net/enve/SyDpX/

演示:http: //jsfiddle.net/enve/SyDpX/

回答by nbrooks

Note: to use jQuery, you must include it by adding something like:

注意:要使用 jQuery,您必须通过添加以下内容来包含它:

<script type='text/javascript' src='//ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js'></script>

To hide it with jQuery:

用 jQuery 隐藏它:

<script type='text/javascript'>
    $(function() {
        $('input[type="text"]').first().hide();
    });
</script>

To disable it, substitute this into above:

要禁用它,请将其替换为上面的:

$(function() {
    $('input[type="text"]').first().prop('disabled', true);
});

回答by Taz

CSS attributes:

CSS属性:

HTML attributes:

HTML 属性:

回答by mr.soroush

use this to disable textbox:

使用它来禁用文本框:

<INPUT TYPE="text" NAME="firstbox" disabled>