How to make a boolean variable switch between true and false??
Question

Hello everyone,

I would like to create a click button that prevents user multiple clicks.

Firstly I add the boolean variable and set it false.

When the user clicks the button,  it becomes "true".

when it becomes true, the button disappears.


like the following HTML script.

<button id="btn" style="display:block;" onclick="prevent_multiple_clicks()">Submit</button>

<script>

function prevent_multiple_clicks() {

  document.getElementById('btn').style.display = "none";

}</script>

or make the button disabled


Thank you very much

mvp_badge
MVP
Solution

Hi there,


You just need to control the IsEnabled variable on your action when you want to block it or not.

I send you the OML in attachment with an example.


Kind Regards,
João

button.oml

mvp_badge
MVP

Hi Tommy,


Usually, the behavior is when you click the use sees the button in a loading status (instead of invisible) so it cannot be clicked multiple times.

If you are working with Reactive or Mobile applications, you have available the ButtonLoading widget from OutSystemsUI:


Another option is to have a boolean variable and place it in the Enabled property of the button:


Then on the beginning of the action you can set it to False (and AJAX refresh it, if you're working on Traditional Web) and set it to True in the end  (and AJAX refresh it, if you're working on Traditional Web).


Kind Regards,
João

Hello João ,

Thank you for your reply.

I just create a simple demo, When the user clicks the button, it displays a loading icon in the button.

What should I apply in this blank?

 


Here is my project...

Thank you very much


button.oml

mvp_badge
MVP
Solution

Hi there,


You just need to control the IsEnabled variable on your action when you want to block it or not.

I send you the OML in attachment with an example.


Kind Regards,
João

button.oml

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.