?
Solved

Stop Form from Submitting Again on Refresh or Back Button

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

Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

Question has a verified solution.

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

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
What You Need to Know when Searching for a Webhost Provider
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

765 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