Andy’s Blog: Application Express etc.


ApEx: Ensuring a button is clicked only once

Posted in ApEx by Andrew Tulley on September 16, 2007

 5.jpg

THE EFFECT

Click here to view the effect. You will notice that as soon as you click either of the buttons, the button is greyed out and its text is changed to “Submitted…”

STEP 1

Create a button of type “Create a button in a region position”.

STEP 2

Set the button’s target to be a URL.

target_is_a_url.jpg

STEP 3

If you do not want a confirm dialog with the button, set the button’s URL target to the following (Note: The below has been put on 3 lines for ease of viewing but should be entered into the URL target all as one line of text):

javascript:this.disabled=true;
this.value='Submitted...';
doSubmit('XXXXXX');

If you DO want a confirm dialog with the button, set the button’s URL target to the following (Note: The below has been put on 4 lines for ease of viewing but should be entered into the URL target all as one line of text):

javascript:if (confirm('Are you sure you want to?')) {
this.disabled=true; this.value='Submitted...';
doSubmit('XXXXXX');
}

In either case you should change the value of XXXXXX to be the same as the name of the button. This is the value that REQUEST will be set to when the button is clicked. By setting it to be the same as the name of the button it means that you can still use “When Button Pressed” conditions for this button.

2 Responses to 'ApEx: Ensuring a button is clicked only once'

Subscribe to comments with RSS or TrackBack to 'ApEx: Ensuring a button is clicked only once'.

  1. Heinz said,

    Hi,
    I tried your second suggestion. The confirm-message is displayed, but the text of the button was not chenged to “submitted…”.
    May be it’s because I use theme 3 ?

    Regards,
    Heinz

  2. Patrick said,

    Hi,

    there is also a built-in feature of Oracle APEX to prevent double submission. Check out the page property “Allow duplicate page submissions”. It’s probably not that nice as your solution but very easy to use.

    Greetings
    Patrick


Leave a Reply