Form input text box that doesn't clear?

Form input text box that doesn’t clear?

Hi all

Is it possible to have input text area that doesn’t clear when a submit button is pressed.
In this example here - http://www.ttmt.org.uk/form/ if I enter text in the box then click the submit button the text box clears - I want to keep the text in the text box.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

	<title>untitled</title>
	
</head>

<body>
  <form action="" method="" >
    
    <input type="text" name="text" />
    <input type="submit" value="Set &rarr;">
  </form>

</body>
</html>


You are submitting the form to the same web page it is in.

So one option is to use the form’s GET or POST value of the input text area to set the default value for the text area when the page reloads after you have submitted it.

How would I do that ?

Are you using PHP to process your form? If so, you can make your inputs “sticky”, meaning that what’s entered into a field stays there after submission.

An example would be as follows:

<textarea name="comments">
    <?php if (isset($_POST["comments"])) {echo $comments;} ?>
</textarea>

This thread probably should be moved to the PHP forum.