Solved

Stop Form from Submitting Again on Refresh or Back Button

Posted on 2003-10-22
5
189 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
  • 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem to get function 52 100
Web Site Hosting 10 79
http to https 3 43
DNS @ Naked Domain Record 5 67
This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

910 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now