Setting checkbox states

I have a series of checkboxes with an option to select all

https://hyo0dn.axshare.com

I have a toggle function for the select states which works fine until you deselect some of the child checkboxes, then it goes out of sequence.

How can I force the Select all checkbox to select and deselect the checkboxes despite the states of the child checkboxes changing?

The logic I came up with was:

There is a global variable called “counter”
On click Select all, read counter variable value and if zero or even hide all checkboxes else if value of counter is odd show all checkboxes; set counter = [[counter+1]]

But I can see now way of telling axure to recognise something as even or odd.

How do I do this select/deselect all functionality irrespective of child states?

Hey there -

A few things:

  1. You get out of sync because you are using the “toggle” action which says to flip the state to opposite of whatever it is. You’ll need to change your logic to look at the state of the select all widget and set the children specifically to that state. I can’t tell very well from the link how exactly you’re checking the box. Are you using dynamic panels or showing/hiding items? Can you share your RP file so I can be more specific? Sometimes repeaters can be helpful for this approach if you’re creating your own custom checkboxes.

  2. I am not following why the even/odd matters? I’m guessing you want to have logic that checks if the number of selected checkbox is equal the total number of checkboxes and then select or deselect the all option accordingly? If so, you could just check to see if the counter is equal to the number of checkboxes you have.

  3. If you ever need to tell if something is even in odd or axure, you can use the “modulo” operator - %. So for example you could do something like value [[counter % 2]] equals value 0 for even, etc:

here is the axure file.

select test.rp (56.7 KB)

Hey there…

The attached does what you’re looking for, I think…

You’ll notice I added some logic to the click on select all. I also put logic on the show/hide of the check marks that will update the select all status accordingly.

select test.rp (61.9 KB)

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.