• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to disable submitting more than once

 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi ALl
How to Disable Submitting More Than once if Imgae is used for
submitting ?.

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a way to do it in JavaScript, if you are using the onClick button. Basically you assign a variable a value of zero and increment the value once the button is clicked. then you run a conditional statement to make sure the var is not greater than 1. Something like this:
var submitCount = 0;
onClick () {
submitCount++;

if (submitCount > 1) {
//do not submit the form
}else{
//submit the form
}
}
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We have used the approach recommened above but ran into the following problems.
1) When the user clicked the Stop button after making the request they basically had to close the browser and restart. Does anyone have a nice fix for this besides capturing the Stop button and resetting the flag?
2) The user can hit the refresh button and resubmit the last request.
We determined that javascript can be helpful in preventing mutliple submits but the situation really needs to be handled on the server.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You might want to try this:
onSubmit='if (this.submitted) return false;
else return somekindjavascriptfunction(this); '
to the <FORM> tag

The javascript file can simply set
this.sumbitted =true;
return true;
or do some edit check first and then set the submitted to true before return true.
So after one successful submission, the subsequent submissions are disabled.
Hope it helps. It did the trick for me.
Soft Music
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys, the server side solution is to use teh so called synchronizer token. The basic idea is, you put a hidden field in the form that contains a unique value, and you put this value in session. When the user submits the form, you check the hidden field, if the value is same as in teh session, this is a valid submition. you take off the object from session and process the request. If those two does not match, this is a duplicate submition (or a very late one).
If you need code example, feel free to ask.
 
reply
    Bookmark Topic Watch Topic
  • New Topic