You need to sign in to do that
Don't have an account?
Multiple clicks to Submit button causing multiple identical records
I have created a custom web form to enter information into a custom object. Everything works great except for the submit button. We recently had someone enter two identical records almost immediately so I went into our sandbox to test my theory and, unfortunately, I was correct...if you click the submit button multiple times before the page processes and redirects to the thank you page it will generate multiple identical records based on the number of times the button was clicked. Is there anything that can be done to ignore the multiple clicks and process only one record instead of duplicating it?
Thanks!!
Hi,
One thing you can do this functionality after click on submit button you can disable the button so that you can avoid duplicate records.
I have researched that and lack of experience/time can't determine best method of coding. it won't let me code in controller extension (unless coding it incorrectly). Tried in the page, within the form, and every time I click anywhere on the page (to enter data) it tries to submit the page, but obviously gives me a bunch of errors since I haven't entered any data. Tried putting code outside of form and that did nothing.
Any help in proper implementation would be greatly appreciated, an example possibly...
<apex:commandbutton onclick="Disablebutton()" action="{!dummy}"/>
<script>
function Disablebutton()
{
document.GetElementById(pageid:formid:componentId).disabled = true;
}
</script>
Will that interfere with submitting the form and redirecting the page to a thank you page?
Tryout with the above sample code and let me know if there is any conflict ....
You will have to excuse my lack of experience...I tried incorporating that into my page, but it didn't like that at all. I will try other avenues of getting the code you suggested into my page and will let you know.
Thanks!
I have the same problem, and the JS code doesn't work... =(
The JS Code works, my bad ! Thanks :)
How did you implement the code to get it to work?
Exactly like sjain1.2523113033806995E12 said, i added onclick="Disablebutton()" on my apex:commandButton, and i copied the script
function Disablebutton()
{
document.GetElementById(pageid:formid:componentId).disabled = true;
}
</script>
just below my commandButton, and it works :)
Ok, it's not working so I am including the code below to see if I can get any suggestions. This is the code in the page itself...
This is the code in the class extension...