Change button color when is pressed?

Hello,

How can I change the color of the buttons when its pressed (when someone click on it)


Cheers!

David Fernandes wrote:

Hello,

How can I change the color of the buttons when its pressed (when someone click on it)


Cheers!

Hi,

Use onClick Event Action for the buttons & apply CSS to the respective button.

1- Pass Button ID to Button OnClick Action

2- Use below JS under the onClick Action

document.getElementById("buttonID").style.backgroundColor = "lightblue";


assif_tiger wrote:

David Fernandes wrote:

Hello,

How can I change the color of the buttons when its pressed (when someone click on it)


Cheers!

Hi,

Use onClick Event Action for the buttons & apply CSS to the respective button.

1- Pass Button ID to Button OnClick Action

2- Use below JS under the onClick Action

document.getElementById("buttonID").style.backgroundColor = "lightblue";


For web applications right?


David Fernandes wrote:

assif_tiger wrote:

David Fernandes wrote:

Hello,

How can I change the color of the buttons when its pressed (when someone click on it)


Cheers!

Hi,

Use onClick Event Action for the buttons & apply CSS to the respective button.

1- Pass Button ID to Button OnClick Action

2- Use below JS under the onClick Action

document.getElementById("buttonID").style.backgroundColor = "lightblue";


For web applications right?


Can be used for web or Mobile too


Without using JavaScript it can done.

Suhas Jamdade wrote:

Without using JavaScript it can done.

Hi Suhas,

I totally agree there is some other approach too :

1- Creating a Boolean variable & setting it on Button Click event.

    And using it in Style class like : if(isBtnClick, "ActiveCSSClassName","DeActiveCSSClassName")

2-It can be done by overriding the Button Default CSS of Outsystems

3- JavaScript [Mention above]

It totally depends on the business requirement & feasibility of screen to with particular approach.

- Assif

Hi David,

Have you solved your issue? If so, can you mark as solution the post that answered your question? If you followed a different approach, can you share it with us, so that everyone can learn from your experience?

Thanks!

Just as an afterthought, given your example, it seems like you are trying to create buttons that behave like radio buttons (the selected one is pressed, the other isn't)... this is already implemented with Button Group in OutSystems UI.