Home > ApEx > ApEx: Ensuring a button is clicked only once

ApEx: Ensuring a button is clicked only once

 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.

Advertisements
Categories: ApEx
  1. December 13, 2013 at 8:54 am

    another alternative is to use jquery :

    $(‘:button’).click(function(){
    $(“:button”).attr(“disabled”,”disabled”);
    setTimeout(‘$(“:button”).removeAttr(“disabled”);’,1500);
    });

    put this in a global js file and reference it in ever page in your app and then every button will “disable” for 1.5 seconds and then re-enable itself. ie preventing double-clicking of buttons

  2. Paul
    June 8, 2010 at 11:44 am

    Hi,
    I don’t get it to work. Just like Heinz, the doSubmit works, but the button remains active.

    Any suggestions?

  3. Alexander
    April 29, 2010 at 1:09 am

    Hi, i try

    javascript:this.disabled=true;this.value=’Submitted…’;doSubmit(‘XXXXXX’);

    but doesn’t work, it needs a special template ?

  4. Natarajan
    August 20, 2009 at 1:29 pm

    Hi,

    We used the second option in many of our pages. Since most of our report pages have with the button with same names, we would like to put this at application level and want to use for each button. We created a shortcut having this as the source for the shortcut and refer the shortcut name in the url redirect, that simply generates only the shortcut name so get an error.
    Is there any way to do that.

    Thanks in advance.

  5. Heinz
    January 15, 2008 at 3:05 pm

    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

  6. September 16, 2007 at 12:25 pm

    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

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: