|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
What is the best way to stop people from pressing the submit button more than once and having mutiple insertions. Basically when a user clicks submit 3 or 4 times i get 3 or 4 signatures in my guestbook
Cisk |
|
#2
|
|||
|
|||
|
You can try the following:
in the form tag, add: <form .... onSubmit="checkifsend()"> and create a Javascript function like: function checkifsend() { if (Hasbeensend) {return false} else {Hasbeensend=true; return true} } Note:Hasbeensend has to be defined as false when loading the page, inside the <script> section. Explanation: When the form is send, the script checks if it has been sended before. If it's the first time, it changes the value of Hasbeensend to true and submits it, avoiding other submits. |
|
#3
|
|||
|
|||
|
I really don't understand how it's possible to submit more than once, unless the form ACTION is to submit to itself (rather than forward the values to another page).
Basically, once you hit submit, the page to which the ACTION goes starts loading immediately, so it's impossible to click the same button twice. I've even tried using the middle button of my mouse (which is configured as a double-click) to submit a form and I only get one action. I would guess that there are two possibilities: 1. the form ACTION is handled inside the same file in which the user fills out the form, thus presenting the button for a second click 2. the user is not clicking the button twice, but is refreshing the page after submitting, which submits the page again. That would require some other code, perhaps using a cookie. If I'm wrong, please explain, because I have never been able to reproduce the "double-click submit" phenomenon. |
|
#4
|
|||
|
|||
|
Argrajoca:
Thanks a lot! That works great ![]() rycamor: Well youre right. The form calls the same page. I've trie drefreshing the page, after submission, and it has never re-submitted information using both GET and POST. I have another contact form on my webpage that spans 2 .php pages and i'm going to test out submitting more than once on that one. http://www.txraves.org/djcisk/signbook.php - is the page that i have the form in. I also used the .disable javascript functiont to disable the button Cisk |
![]() |
| Viewing: Dev Shed Forums > Web Design > HTML Programming > Mutiple Submits |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|