Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9263233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T13:32:13+00:00 2026-06-18T13:32:13+00:00

This is php/html form textarea code <textarea name=txtDispMsg cols=1 rows=1 value=<?php if(isset($disp_msg)){echo $disp_msg;} ?>

  • 0

This is php/html form textarea code

<textarea name="txtDispMsg" cols="1" rows="1"  value="<?php if(isset($disp_msg)){echo $disp_msg;} ?>" <?php if(isset($flag) && $flag == 4){echo "div style = 'border:2px solid red;'" . "/div";}?>></textarea>

here i m checking if user has entered the value in textarea it shall stay there whether there is any other error in form.. so the data in other fields in form stays there.. but not textarea. why?

Am i using wrong method of setting/fixing value to textarea? Though it works in the case of normal text fields

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T13:32:14+00:00Added an answer on June 18, 2026 at 1:32 pm

    Value is not an attribute of the Textarea tag in HTML syntax. If you want to display content within the Textarea, you must place the content between opening and closing Textarea tags. You are trying to set the content by declaring value=”content” and instead you need to do the following:

    <textarea name="fieldName" cols="15" rows="4">CONTENT GOES HERE</textarea>
    

    SEE: http://www.w3.org/wiki/HTML/Elements/textarea


    If you want your values to not clear when you submit, then you must process them at the top of the page looking for some action, and then set the values of them in the form.

    <?php
    
    // check if values submitted to page and if not, set empty value
    // add html escaping just in case
    $field1 = (isset($_GET['field1'])) ? htmlspecialchars($_GET['field1']) : "";
    $field2 = (isset($_GET['field2'])) ? htmlspecialchars($_GET['field2']) : "";
    $field3 = (isset($_GET['field3'])) ? htmlspecialchars($_GET['field3']) : "";
    $field4 = (isset($_GET['field4'])) ? htmlspecialchars($_GET['field4']) : "";
    
    // toggle radio button if one was selected
    $on = ($field4 == "1") ? "checked" : "";
    $off = ($field4 == "0") ? "checked" : "";
    
    ?>
    
    <html>
    <head><title>Test Page</title></head>
    <body>
    <h1>Test Page</h1>
    <form action="test.php" method="GET">
    Field 1: <input type="text" name="field1" value="<?php echo $field1; ?>" /><br />
    Field 2: <input type="text" name="field2" value="<?php echo $field2; ?>" /><br />
    Field 3: <textarea name="field3" cols="15" rows="5"><?php echo $field3; ?></textarea><br />
    Field 4: On <input type="radio" name="field4" value="1" <?php echo $on; ?> /> &nbsp; <input type="radio" name="field4" value="0" <?php echo $off; ?> /><br />
    <input type="submit" value="Submit" />
    </form>
    </body>
    </html>
    

    Of course you can add your additional logic and styling but the main issue with your code was bad HTML syntax and textarea is different than other form tags and has no ‘value’ parameter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<form action=mail.php method=post target=_blank> <textarea name=mess cols=50 rows=5></textarea> <input name=send type=submit value=Send> </form> After
I am using the code below: <form> <textarea cols=50 rows=4 name=link></textarea> <textarea cols=50 rows=4
For example… This PHP code <?php echo '<html>'; echo '<body>'; echo '<h1>Header One</h1>'; echo
I have this code for form submit: index.php <html> <head> <title>My Form</title> <script type=text/javascript
The code looks like this: html <form action=contact.php method=post enctype=multipart/form-data onsubmit=return Validare();> <input type=text
This piece of valid json (it has been generated using php's json_encode): {html:form is
Is something like this possible: <form method=post action=myphp.php name=myname target=another_html/iframe_name>??? I want the php
this is my HTML: <?php echo form_open(base_url().'admin'); ?> <div class=row username> <span class=icon></span> <input
this is html from <form action=http://localhost/own/import.php method=post enctype=multipart/form-data name=form1> <input type=file name=xmlfile id=file1> <input
I have this HTML: <form action='uploadhandle.php' method='POST' enctype=multipart/form-data> <input type='file' class='fileinput' id='photo1' name='photo1'> <input

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.