Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Value attribute in textarea bootstrap 3

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

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.

For some reason though its not working with my 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

<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 ?

like image 718
Nick lK Avatar asked Jan 06 '14 00:01

Nick lK


People also ask

Can textarea have value attribute?

<textarea> does not support the value attribute.

Can I add value to textarea?

To add a value into a textarea, you can add to the value property of the input via document. getElementById. Reference this element and change the value: document.

How do I display textarea content in HTML?

Use the <textarea> tag to show a text area. The HTML <textarea> tag is used within a form to declare a textarea element - a control that allows the user to input text over multiple rows. Specifies that on page load the text area should automatically get focus.

How do I restrict characters in textarea?

Note − By default, we can enter data in a textarea upto 5,24,288 characters. In some cases, there is a need of putting a limit on the size of characters that can be typed in a textarea. So in that case, we can use maxlength attribute to control the number of characters entered in a textarea.


2 Answers

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

<textarea class="form-control" id="message" name="message"  rows="5">hi</textarea>
like image 78
oxfn Avatar answered Oct 24 '22 19:10

oxfn


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

<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>
like image 43
BENARD Patrick Avatar answered Oct 24 '22 17:10

BENARD Patrick