How do you set a default value for a 'textarea'?

Posted on 2010-01-06
Medium Priority
Last Modified: 2013-12-12
I've got a form with a ' textarea' as I am trying to capture textual input of an undefined length (a blogg would be an example of this - the field is defined as 'text' on the mysql database) but it does not seem to be possible to set this with a default value. How can I set this area with the information such as it is that has already been captured and committed to the database (I want it to be open and available to be updated)?
Question by:me_patrick
LVL 40

Accepted Solution

Gurvinder Pal Singh earned 500 total points
ID: 26191018
like this
<TEXTAREA NAME="comments" COLS=40 ROWS=6>
John said
: I think it's a great idea
: but it needs more thought

Just put the value between the starting and closing tag
LVL 11

Assisted Solution

VanHackman earned 500 total points
ID: 26191036


<textarea rows="2" cols="20">
Your Default Information.

if you have the information  already captured in a variable named "$Text" :

<textarea rows="2" cols="20">
<?php echo($text); ?>

Assisted Solution

code-colors earned 500 total points
ID: 26191038

If you are using ASP, then try the below code.

TextAreaValue = "DefaultValue"

<textarea name="txtTextArea"><%=TextAreaValue%></textarea>

And you can use Request.Form("txtTextArea") to get the text area value when you submit the form.

Try It!
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 500 total points
ID: 26191126
If you are sending out data that was received from outside your control, you have a  very important security issue here.  Do not just "echo" the data from your DB entry.  Instead you want to do something like this to avoid contaminating your clients with malicious code:

echo "<textarea>";
echo htmlentities($text_from_database);
echo "</textarea>\n";

Always... Filter Input / Escape Output!

Best regards, ~Ray
LVL 11

Expert Comment

ID: 26191229
"I set this area with the information such as it is that has already been captured and committed to the database"

"Do not just "echo" the data from your DB..."

If you have to filter data that is already in your DB, I think that the security issue will be in another part of your system.... =P

Author Closing Comment

ID: 31673504
Yes of course - sorry, I've been an absolute nit-wit .... trying to think about too much at the same time.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This holiday season, we’re giving away the gift of knowledge—tech knowledge, that is. Keep reading to see what hacks, tips, and trends we have wrapped and waiting for you under the tree.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question