Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2011
    Thanked 0 Times in 0 Posts

    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"
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
      <form action="" method="" >
        <input type="text" name="text" />
        <input type="submit" value="Set &rarr;">

  2. #2
    Master Coder sunfighter's Avatar
    Join Date
    Jan 2011
    Thanked 1,016 Times in 1,013 Posts
    This is how the textarea works. If you want to keep the info in the textarea you will need to
    1.) use javascript to collect it's contents and re-write it back once form is submitted.
    2.) use html5 (which won't work in IE of course). Think its called placeholder (a tag). I did experiment with keeping the text area safe from losing info, but I could find no way to destroy the info from the script. The user had to do it. I didn't like that so never used it on a site.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts