Solved

RESET FORM DATA AFTER SUBMIT

Posted on 2003-12-05
6
1,694 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
[X]
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
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

Title # Comments Views Activity
Bypass cross origin issues on development site 3 95
Html value of radio 14 44
Asp response.write to clients 6 34
window close link 7 35
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

749 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