Use count of 'checked' checkboxes in a variable to control corresponding UI controls?

Troy Surdick shared this question 4 years ago
Answered

Is there a way to count the number of "checked" checkboxes, and use that count to enable/disable related UI controls? (Example, if 0 or 1 checked, disable a corresponding drop-down list and button; if 3 or more checked, )?


I'm trying to use a variable ("checked_count") with default value of 0. When I 'check' one of the checkboxes, I'm adding a conditional event (if IsChecked = true, then (checked_count = checked_count + 1). Else, (checked_count = checked_count - 1). My thinking is that I would then be able to use the value of checked_count to set active panel, or enable/disable controls as needed. However, I don't seem to be having much success.


Can anyone please weigh in on whether or not what I'm thinking is sound? (I'm new to Justinmind, so it would be helpful to know if I'm just completely off base...)


Thanks!

Comments (2)

photo
1

Hello Troy,


You can add an event (‘on change’) on each checkbox. Using the "Set Value" event on the checked_count variable which adds 1 to a variable when it’s checked or subtracts 1 when is unchecked.


Below is a screenshot of your events.


e81f8b78e26b881521cac1a64d37d1c4


Let me know if further clarification is needed.


Best

photo
1

Thank you!