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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.