Html textarea bootstrap 3 中的值属性

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20941272/
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-29 00:20:24  来源:igfitidea点击:

Value attribute in textarea bootstrap 3

htmltwitter-bootstrap

提问by Nick lK

I have a textarea I use as a form on a website.

我有一个 textarea 用作网站上的表单。

I usually use place "placeholder" text inside, but I need this information to come up editable.

我通常在里面使用地方“占位符”文本,但我需要这些信息来编辑。

What I used to do was just feed info from my database into the "value" attribute of the form. The form would then just pop up with my data, ready to be edited.

我过去所做的只是将数据库中的信息输入到表单的“ value”属性中。然后表单会弹出我的数据,准备好进行编辑。

For some reason though its not working with my textarea!

出于某种原因,尽管它不适用于我的 textarea!

Here is my code:

这是我的代码:

<textarea value='<?php echo $info?>' class="form-control" id="message" name="message"  rows="5"></textarea>

I know its not the data because iv echoed it elsewhere and its fine. I also tried

我知道它不是数据,因为 iv 在其他地方回应了它并且很好。我也试过

<textarea value='hi' class="form-control" id="message" name="message"  rows="5"></textarea>

with nothing showing up.

什么都没有出现。

Whats going on ? I used to do this all the time. Im using bootstrap 3, could it have something to do with that ?

这是怎么回事 ?我曾经一直这样做。我正在使用引导程序 3,它可能与此有关吗?

回答by oxfn

<textarea>tag doesn't have valueattribute http://www.w3schools.com/tags/tag_textarea.aspContent should be placed between opening and closing tags

<textarea>标签没有value属性http://www.w3schools.com/tags/tag_textarea.asp内容应该放在开始和结束标签之间

<textarea class="form-control" id="message" name="message"  rows="5">hi</textarea>

回答by BENARD Patrick

In order to put some text in a textarea you should write something like

为了在 textarea 中放置一些文本,您应该编写类似

<textarea class="form-control" id="message" name="message"  rows="5">hi</textarea>

or

或者

<textarea class="form-control" id="message" name="message"  rows="5">
     <?php echo $info ?>
</textarea>

回答by baig772

text area does not have value, put the text between opening and closing tags for example

文本区域没有值,例如将文本放在开始和结束标记之间

<textarea name="myText">
this is text area
</textarea>

回答by Miladul

<textarea name="message"  rows="5">
    <?php echo $variable_or_any_php_code?; >
</textarea>