Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Stop Form from Submitting Again on Refresh or Back Button

Posted on 2003-10-22
5
Medium Priority
?
196 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 400 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

Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

Question has a verified solution.

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

Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

604 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