Log in

View Full Version : Textarea input wiped out after form submission



Landslyde
02-20-2015, 03:33 AM
And this is an issue because if the user has made a mistake on the form and has to make a correction, he/she also now has to retype everything in the textarea again before re-submission. And the textarea's the only input device that loses its input. Input boxes are fine, as are the selected select options. Is this a natural behavior? Is there a way around it?

Beverleyh
02-20-2015, 12:39 PM
You can use a script like this to retain data (JavaScript): http://www.dynamicdrive.com/dynamicindex16/autosaveform.htm

You can also use PHP to post the data back to the form field once it has been submitted - something like this (very simple example);

Top of page;
$comment = $_POST['comment'];

Markup;
<input type="text" name="comment" value="<?php echo $comment ?>">

or
<textarea name="comment"><?php echo $comment ?></textarea>

If you need more help, please provide a copy of your script.