Double-clicking "Ok" on a record-creating pop-up

Double-clicking "Ok" on a record-creating pop-up


We have a RichWidgets pop-up that, when you click "Ok", creates some new records in the database and closes the pop-up. Some end-users like to double-click the "Ok" button, which, if they're fast enough, creates two duplicate records in the database. Is there an elegant way to prevent that from occurring?

Hi Mickey,

It's wonderful when your users like to play the 'happy trigger', isn't it? :)

I see it 2 ways:

Javascript: once the button is clicked you submit a hidden Link (Method=Submit) to call your screen action. In your button Extended Properties, add the onclick event, through this sample code:
this.disabled = true; return false;
'return false' avoids your button submitting the form and 'this.disabled=true' avoids your users to resend it as well. Meanwhile your hidden link is already doing the rest of the work.

Server-side tokens: when your popup opens you generate a token (use the GeneratePassword built-in function); this token is then sent to the server once your button is pressed and saved on the database or a local variable. This way you can be sure that only one request is valid for that popup session.

Let me know if that worked for you!

Hi Pedro,

Thank you for the advice! As it's not really a data-integrity issue (users are free to intentionally create more records, they just don't like it happening accidentally) I went with a Javascript solution.

I don't think I understood what you meant about submitting a hidden link? How is that link getting triggered when the button is clicked?

That being said, simply adding "this.disabled = true;" to the onclick extended property seems to have done the trick for me, so thank you for setting me on that track!

- Mickey
Glad you solved it with the Javascript disable script. Just be sure to test other browsers (you never know if there are different behaviors).

By submitting a hidden link I meant calling RichWidgets\Widget_Click action from your button screen action. That action would then "click" a link on your page (which could be conveniently hidden with an Extended Property style="display:none;" Then your hidden link would actually perform the data recording which we've been discussing above. Honestly, if the disable script works fine, don't go for this solution since it involves a lot of requests between client & server.