Jump to content

Setting value of textarea


chrisredding

Recommended Posts

Hi,

 

I have a script that checks and submits a contact form. It all works fine, but I have a small niggle...

 

Each input field has some PHP to set it's default value, so that if the user submits the form and one or more of the fields is rejected for some reason, and the form refreshes, the fields retain their default values. This works fine on the 'input' fields, but doesn't work on the 'textarea'.

 

You can take a look at the form here:

 

http://www.chrisredding.com/v4/gen/form/contact.php

The code for this problem area is below:

 

 

<fieldset id="fieldset">
<label for="comments">Message : </label> 
<textarea name="comments" id="comments" type="text" class="textb" tabindex="40" 
    cols="40" rows="10" value="<?php echo $_POST['variable'];?>"/>
</textarea>
</fieldset>

 

 

So if the user fills in their name, email and a message, but gets the CAPTCHA code wrong for instance, their message disappears. Which would annoy the hell out of me! But their name and email remain as they have filled them in.

 

Any idea why this might be?

 

I've included the code for one of the fields that does work here:

 

<fieldset id="fieldset">
<label for="email">Email : </label> 
<input name="email" id="email" type="text" class="textb"
    tabindex="1" value="<?php echo $_POST['variable'];?>" size="30"/>
    <br />
</fieldset>

 

(I've hidden my variable names!)

 

Many thanks,

 

Cheers

 

Chris

Link to comment
https://forums.phpfreaks.com/topic/38030-setting-value-of-textarea/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.