Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I "pre-fill" the value of a textarea in an HTML form? [duplicate]

Tags:

html

forms

I'm creating a simple back-end app through which the user can create/update/delete database rows (in this case, job listings).

When it comes time for the user to edit an existing listing, I'm trying to pre-fill most of the HTML form with the data from that existing row. I've done this sucessfully for text inputs using the "value" property, and with selects using a bit of php in each option tag: if([conditionforoption]){echo'selected'}.

The input type that I'm having trouble pre-filling is the textarea... any thoughts on how to get the existing data (a long varchar string) to be present in the textarea input when the user loads the page?

I'm trying to stay away from a javascript solution if at all possible, but I'll use it if necessary.

like image 749
jasonmklug Avatar asked Feb 09 '10 19:02

jasonmklug


People also ask

How do I autofill textarea in HTML?

The HTML <textarea> autocomplete Attribute is used to specify whether the Textarea field has autocomplete on or off. When the autocomplete attribute is set to on, the browser will automatically complete the values based on which the user entered before.

Can I use textarea in a form in HTML?

Yes you can use textarea tags outside of a form and they will display and allow text to be inserted and edited, but not being tied to a form their uses will likely be limited.

Can we use value attribute in textarea?

From the MDN documentation: " <textarea> does not support the value attribute".


1 Answers

<textarea>This is where you put the text.</textarea> 
like image 85
AGoodDisplayName Avatar answered Oct 15 '22 14:10

AGoodDisplayName