Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

RESET FORM DATA AFTER SUBMIT

Posted on 2003-12-05
6
1,692 Views
Last Modified: 2011-09-20
Hi i'm new to the forum, as far as posting is concerned.
I've searched about and about on this topic, and have found numerous topics, but none to explain really exactly what I need.

I am submitting data from a form to an SQL db, and works great and fast.
I redirect to confirmation page after submission.

My question is how do I make the form reset after I post?
I see a bunch of stuff, but am lost
Any help would be greatly appreciated.

Here's the code:

<form name="form1" method="POST" action="/jmm/test.asp?" onSubmit="nrt_validateForm('firstName','','R','lastName','','R','homePhone','','RisNum','workPhone','','NisNum','mobilePhone','','NisNum','emailAddress','','RisEmail','comments','','R');return document.nrt_returnValue">
0
Comment
Question by:jmazur01
  • 3
  • 2
6 Comments
 
LVL 1

Expert Comment

by:Macorc
ID: 9881656
If you post the form to a new file ... the browser window should replace the old document with the new one, isn't it?

I don't understand the question. If the browser window gets replaced, why do you need to reset the form? it will be destroyed anyway.
0
 

Author Comment

by:jmazur01
ID: 9881722
Ok, well if the user goes back to the page, the data is still there and he/ she can re-submit
If he/she hits refresh, the data is re-sent to the SQL server

thanks for the prompt reply  
0
 
LVL 18

Expert Comment

by:SquareHead
ID: 9882131
Maybe this would work:

When you submit the form, also set a session variable -- something like Session("form_submitted") = "yes"

Then check for that session var whenever the form page loads -- either through normal methods, or by hitting the back button, and if the session var is there and it says "yes", then execute a javascript that resets the form...

Another option is to submit the form to a separate page that does the processing, then redirects the user back to the original form page...

0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 1

Accepted Solution

by:
Macorc earned 250 total points
ID: 9882384
Ok, I understand. Both options from SquareHead seem good to me, though didn't try them. Another solution could be to reset the form always when the page loads. Something like:

<body onload="document.forms['FormName'].reset()">

I didn't try this either to check if it is really working when going back with the browser button.
0
 
LVL 1

Expert Comment

by:Macorc
ID: 9882397
By the way, If you don't want the user to be able to re-submit the data you should do what SquareHead says, and have every different step in the process in a different file.

Form->Process->Confirm success
0
 

Author Comment

by:jmazur01
ID: 9882877
Thank you all so very much!
that worked perfect!

Have a Safe and Happy Holiday Season!!

--jmm
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question