[thelist] How do I clear form input fields onSubmit (or somehow)?

Simon sentient at mm0.net
Wed Aug 2 17:05:29 CDT 2000


I'd posted here asking [snipped]:
>>  So what I'd like to know is whether it's possible to clear the
>>  contents of those three fields at the time the form contents are sent
>>  without having to reload the parent page in the background. Ideally
>>  I'd like to just clear the contents, leaving the rest of the page
>>  alone.

And "Theodore Serbinski" <need-4-speed-ski at erols.com> suggested:
>  Actually it is quite easy to reset your form, just put the
>  following code in your onsubmit handler:
>  document.yourFormName.reset();
>  And voila! Its all cleared.

Thanks for the help on this. I forgot completely about needing to 
give the form a name attribute so I could do this. Now I've got all 
the forms working exactly as I'd hoped.

>  However I think your best bet would be to take the user back
>  to the previous page after submitting form. If you think
>  about, I go to this page, type all my stuff in, hit submit
>  and a little window pops up and than all of the things I
>  typed in are gone, I might get a little scared as to whether
>  or not my comments weren't sent in (despite the thank you
>  window).

Good suggestions. In our case we have the comment card form on almost 
every page so unless I redirect them to a special "thank you" page 
(in the CGI) they'll almost always wind up seeing another empty 
comment form which they could surmise means their comments were never 

>  If you could find some way to just get rid of the
>  form in all, that would probably be best. And taking them
>  back one page might even be better.

I admit it's mostly a personal thing on my part, but I really don't 
like getting redirected to a "thank you/confirmation" kind of page at 
all when I submit a form if it means I'm just going to have to click 
a link or use my Back button to return to where I'd been a moment 

In this case our little popup confirmation window says all that needs 
to be said. But as you mentioned, an even better solution would be to 
make the table that contains the form vanish and replace it with 
something else. I'm guessing that's possible if we had our pages 
being generated dynamically but since these are static pages I'm not 
sure if it could be done without having to redirect them to a 
different version of the page without the form. And with hundreds of 
pages online it's not a first-choice solution for me.

In any event, thanks for the help with getting my form to clear its 
fields. If I come up with a good way to make the form vanish when 
submitted (on static pages) I'll be sure to post the solution here.


Sentient Technologies - mailto:sentient at mm0.net

   "Any technology distinguishable from
     magic is insufficiently advanced."


Sentient Technologies - mailto:sentient at mail.com

More information about the thelist mailing list