Question:How do I determine (in formula) if all of the boxes of a computed checkbox are checked? (the number of boxes is based on user input)
Subject: checkbox question
Assuming you’re using a formula for your list of choices:
@if(@Elements(fieldname) = @Elements([formula determining the list of choices for the field]); [if it’s true]; [if it’s not])
Subject: RE: checkbox question
I’m using a formula -@Explode(@Implode(checkbox_1; “,”); “,”)
- to get this checkbox_2 from a checkbox that accepts user input. This gives me a checkbox with a variable number of selections and I need to tell if all are checked.
Subject: RE: checkbox question
This formula:@Explode(@Implode(checkbox_1; “,”); “,”)
doesn’t make sense to me. Why don’t you just use checkbox_1 as the formula instead?
Where are you using this formula? Is it the keyword formula for the second checkbox field?
If so, if the user has checked all the selections in the second checkbox field, then this expression will be true:
@Elements(checkbox_2) = @Elements(checkbox_1)
Just like M said.
Subject: RE: checkbox question
That formula doesn’t make sense to me either - I inherited this db from an ex-employee ![]()
But here’s what I have: checkbox_1 has 10 choices, checkbox 2 has whatever choices the user selected in checkbox_1 when the form is saved. So if I pick only 4 choices in checkbox_1, then checkbox_2 (with the weird formula used to calculate the field) generates with only those 4 choices. Can I still tell that all 4 choices are checked by comparing checkbox_1 with 10 choices to checkbox_2?
If I can, I’m doing something wrong - I tried using the suggested formula to calculate a “open / closed” status field, but it just stays open when all the boxes of checkbox_2 are checked.
(and thanks for the quick responses and patience - you guys are great!)
Subject: RE: checkbox question
If you refer to the field name in your formula, you’re referring to the current value of the field. If there are ten, or a hundred, or a thousand choices, and only four of them are selected, then there are four values stored in the field. OK?
Subject: RE: checkbox question
I got it! I’m still not sure I understand how to compare cb1 to cb2 - if cb1 had 4 of 10 checked and cb2 had 4 of 4 checked, I could not get it to say that cb1=cb2. But I finally added a hidden cb3 (using the same formula that built cb2) and used a script to check all the boxes. Now it works when I compare cb2 to cb3. There’s probably a much simpler way to do it, but I just don’t have the skill to make it work an easier way. Thanks for all your help ![]()
Subject: RE: checkbox question
If the only choices available for cb2 are the values checked in cb1, and there are four checked in cb1, and four checked in cb2, how could they not be the same four? That’s why we’ve been telling you to just compare the number of elements.
Of course, we’re assuming that you’re using the field options to refresh fields when cb1 is changed, and to refresh choices on document refresh on cb2.
If for some reason you don’t want to do that, you can always test whether @Sort(cb1) = @Sort(cb2).
Subject: RE: checkbox question
you’re right - I was finally able to make it work by just testing @Sort(@Elements(cb1))= @Sort(@Elements(cb2))
Thanks!!
Subject: RE: checkbox question
OK, I guess that’ll work, but you don’t need @Sort. @Elements returns a single number. E.g. if cb1 has three elements, @Elements(cb1) returns the number 3. So then you’re sorting what? You’re sorting the number 3. What good does that do? Like I hand you one playing card and say, “sort this for me, would you?” You’d just hand it back.