Skip to main content
Solved

Click checkbox to add, uncheck checkbox to minus


James_Willoughby

I have a total and I have a list of numbers. If I click a check box next to the number, I want to add this to the total.
I can do this with variables, but if I click the checkbox again it keeps adding to the total.
How can I set it so that when I uncheck the checkbox the number is subtracted from the total?

Best answer by Edwart

Hi @James_Willoughby

You can achieve this by creating a checkbox component and add the logic to this component. When the checkbox is unchecked and it gets clicked, you add one to the count and change the variant to “checked”.

On this variant add the following behaviour: when the checked checkbox is clicked, subtract one from count and change the variant to “unchecked”.

View original
This topic has been closed for comments

3 replies

Edwart
  • 9 replies
  • Answer
  • July 18, 2023

Hi @James_Willoughby

You can achieve this by creating a checkbox component and add the logic to this component. When the checkbox is unchecked and it gets clicked, you add one to the count and change the variant to “checked”.

On this variant add the following behaviour: when the checked checkbox is clicked, subtract one from count and change the variant to “unchecked”.


James_Willoughby

Bloody hell, I was way overcomplicating that, thanks!!


Certainly! Here’s a translated version of your request in English:


I would like to inquire about implementing a checkbox component with a specific requirement. When the checkbox is unchecked and clicked, I need to add different values each time.

Could you please guide me on how to implement this?


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings