I’m trying to create conditional logic for the below three cases. The first two are easy, and I’ve managed those, but I’m struggling with the third. Is what I’m showing possible in Axure without creating a separate condition for every possible combination?
Triggering Different Actions Based on Number of Checkboxes Selected
Ok it’s not clear what event actually triggers to action (each time you click one?) but the simplest way to do this is probably with a variable to track how many are selected, regardless of which ones, and then do something based on the total of selected checkboxes.
Create a global variable (let’s call it selectedCount with a default value of 0 assuming all checkbox begin unchecked) and put these cases on the OnSelectionChange event of every checkbox:
OnSelectionChange
Case 1
IF selected of this equals true
Set variable selectedCount to: [[selectedCount + 1]]
Case 2
ELSE IF true
Set variable selectedCount to: [[selectedCount - 1]]
Case 3
IF value of variable selectedCount is 0
Do action1 stuff
Case 4
IF value of variable selectedCount is 1
Do action 2 stuff
Case 5
IF value of variable selectedCount is greater than or equal to 2
Do action 3 stuff
Note the IF
versus ELSE IF
, they’re important to the flow of logic through the cases. Instead if you don’t want this to happen every time a checkbox changes, you could move the last three cases to a button or some other event. Leave the first two cases on each checkbox as they do need to happen as the checkbox is updated to properly track how many are selected.
In that case, see my last paragraph. You can move Cases 3 through 5 to the OnClick event of the done button. Keep Cases 1 and 2 on each checkbox.