Solved

Stop Form from Submitting Again on Refresh or Back Button

Posted on 2003-10-22
5
193 Views
Last Modified: 2013-12-24

How do I get a form to stop resubmitting when the user presses refresh or the back button?
0
Comment
Question by:champ_010
[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
5 Comments
 
LVL 11

Expert Comment

by:hart
ID: 9604357
be more specific, have u written the code for updation or insertion on the same page along with the form or what???

Regards
Hart
0
 
LVL 17

Expert Comment

by:anandkp
ID: 9604448
run this code on ur PC & click 2wice on the button & let me know - if it works the way u want it to !

<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"><!--
var myvar = false;    
function chk_duplicate_submit()
{      
    if(myvar)
    {
          alert("pls be patient - while we process ur request !");
           return false;
    }
     else
     {
        myvar = true;
        document.frm.submitme.value = 'Processing ...';
     }
}

function chkForm()
{
    return chk_duplicate_submit();
    // my general form validations here
}
//-->
</SCRIPT>

<FORM name="frm" action="somepage.cfm" method="post">
     <INPUT type="text" name="myname"><!-- more form elements here -->
     <INPUT type="button" name="submitme" VALUE="Continue ..." onclick="return chkForm()">
</FORM>

let me know ....

K'Rgds
Anand
0
 
LVL 11

Accepted Solution

by:
hart earned 100 total points
ID: 9604510
see if u have form that gets submitted to a another page and there itself if u r displaying some things.
then on back button or refresh there will be an alert stating do u want to post the data or not...

so to avoid this the proper way of doing things is this..

say u have form on a page

<form name="frm1" method="post" action="amd_somepage.cfm">
</form>

submit this form to an intermediate page amd_somepagename.cfm [amd is short for add/modify/delete]
there do the appropriate updates or inserts or deletes [with data base]
and then using <cflocation  tag send the user to the next page.

thsi way even if the user refreshes the final page it would never alert u anything :-)

hpe its clear :-)

Regards
Hart
0
 
LVL 1

Author Comment

by:champ_010
ID: 9620123

hart, sorry i read your last post wrong--i think you are saying if i submitt to another page to do the processing--i can cflocation back to the first page that one that the form is one--and that way i can avoid the refresh back button right?
0
 
LVL 11

Expert Comment

by:hart
ID: 9625145
yes if u keep an intermediate page to add modify or delete in the database and then redirect the user to appropriate page then the problem of an alert occuring on refresh will not occurr.

hope its clear

Regards
Hart
0

Featured Post

Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

Question has a verified solution.

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

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

705 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