Hello and welcome to our community! Is this your first visit?
Register
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
    Posts
    37
    Thanks
    0
    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.

    Code:
    <!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>

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,303
    Thanks
    23
    Thanked 612 Times in 611 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.
    or
    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
    •