cancel
Showing results for 
Search instead for 
Did you mean: 

Stop calling onclick() event for multiple clicks

Former Member
0 Kudos

Hi All,

I am calling a function on "onclick" event of a button.

If button is pressed for 2 times, function associated with onclick is getting executed twice.

I think, click event is cached somewhere.

Is there any way to clear the button onclick event upon completion of function call.

request suggestions.

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member192939
Active Participant
0 Kudos

Praveen,

Disable the button once it is clicked, this can avoid the confusion for the user and also for the logic

Regards,

Ajay.

Former Member
0 Kudos

Hi Disabling, will completely disable button.

I want button to be enabled.

This button will be used repeatedly by user. Functionally this is required.

When button is clicked, function executing SAP transaction. When execution is in progress, if user clicks button again(Impatient user), after completion of earlier execution, second execution will be triggered which was un intentional.

But after completion of first execution, button should be enabled so that user can initiate Function if required.

former_member192939
Active Participant
0 Kudos

Praveen,

what i mention here might not be best practice ... this is just my idea..

var a;

onClick()

{

if(a==1)

exit/return;

a=1;

Logic that you will be triggering

settimeout function which sets the value of a to "0", say after 10 sec (depending on the transaction execution time)

}

// if you have an applet... applet update function can be used to set the value of a to "0"

Edited by: Ajay Malempati on Feb 28, 2008 5:23 PM

sufw
Active Participant
0 Kudos

I would stick with Udayan's suggestion on this...

Disable the button as the first action in the called JavaScript function, run the query/update/etc., then re-enable the button.

This way, a user is not able to click the button again while your function is running; but is able to click on it again when your processing is finished.

I've seen a lot of websites which take this approach...

Sascha

Former Member
0 Kudos

Hi,

Enabling and disabling and even setting flag didn't solve my problem.

Finally I have decided to put an alert after completion of process. This has solved multiple click issue.

Thanks for all your response.

former_member192939
Active Participant
0 Kudos

Doesnt sound convincing....;) any how it worked and solved your problem..

Regards,

Ajay.

Former Member
0 Kudos

The function would be executed as many times the event is triggered.That is normal behavior.

Because it is the same session we are talking about ,you can set a flag (true/false) @ the beginning & end of the function for JS to identify if the event has been triggered once or not.

Execute the logic only , lets say , when the flag is true .