SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast Wouter's Avatar
    Join Date
    Jan 2002
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to reset form text automatically?

    How can I reset the text box automatically after the input type image is clicked?


    <form name="myForm" action="http://www.dns.be/nl/cgi/page.cgi" target="_blank">

    <input type="text" name="domainname" id="textbox" size="20" style="font-family: Tahoma; font-size: 8pt">
    <input type="hidden" name="which" value="das"><br>
    <input type="image" border="0" src="images/find.gif" width="52" height="16">
    </form>

    Thanks & Have fun - Wouter

  2. #2
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In the simple example you have given, just add...

    onclick="myForm.reset()"

    ... to whatever tag element you want to use to reset the form, in this case...

    <input type="image" border="0" src="images/find.gif" width="52" height="16" onclick="myForm.reset()">
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature

  3. #3
    SitePoint Enthusiast Wouter's Avatar
    Join Date
    Jan 2002
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the suggestion but using

    onclick="myForm.reset()" resets the form before the input is send to the CGI. I think I have to use a delay or something.

  4. #4
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Wouter
    Thanks for the suggestion but using

    onclick="myForm.reset()" resets the form before the input is send to the CGI. I think I have to use a delay or something.
    fwiw, it's good 'usability' to let the user know more clearly that a form has been submitted.
    Perhaps you might want to consider using a return page.
    This is the most popular option and is very reassuring way of telling the user that stuff has happened.

    An 'on-page' alternative would be to have a div appear when the form is submitted.
    The DIV could have a short notice telling the user that their message has been sent.
    It'll have a close (this 'window') button/image which can be used to hide the DIV and reset the form beneath it.


    If you just want to use a delay then simply try adding this to the submit image...

    onsubmit="setTimeout('myForm.reset()',1000);"

    Simply increase the number by 1000 for every second of delay you want.
    Using this method can create problems on servers with inconsistant speeds (esp slow ones)

    Hope one of these helps
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature


Bookmarks

Posting Permissions

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