I have a name entry form where people enter names for name badges that get written to a MySQL database.
The problem is, if there is a short lag after hitting the "submit" button, it will duplicate the entries. ore even worse, if the user double clicks or triple clicks "submit" (even when the response time is "normal"), there will be double or triple the entries.
How can I avoid duplicate entries?
Duplicate Form Submissions
Moderator: General Moderators
Re: Duplicate Form Submissions
Add this code to your submit button, it will disable it when it is clicked the first time.
onClick="this.form.submit(); this.disabled=true; this.value='Sending…'"
onClick="this.form.submit(); this.disabled=true; this.value='Sending…'"
Re: Duplicate Form Submissions
Great, Thanks! I added the code you suggested and when I click "Submit Names" I see the "Sending..." message but the contents of the form don't get submitted to the database. What should I be looking for as an error?
My code looks like the attached image. (because I am new, some characters in my code are not allowed??)
My code looks like the attached image. (because I am new, some characters in my code are not allowed??)
Re: Duplicate Form Submissions
Hmm, perhaps remove the this.form.submit(); portion. In your browser console you should be able to check for any errors, and also check to see what was posted.