How to extract from 2 neighboring checkboxes and pick only the one that's selected?

I’ve got some questions that have two checkboxes next to them, one for Yes and one for No (screenshot attached).

What is the best way to extract which one is selected i.e. the person should tick one or the other. Nearest checkbox obviously will only return the answer to the first checkbox.

I can’t quite work out how to do this in sensible!

(cross posted into community by admin)

There are two questions here:

  1. how do you get both checkboxes, when they’re so close together?
  2. how do you return just the selected value out of multiple checkbox choices?

For #1, you can still use nearestCheckbox, but you can use an offsetX parameter skip past the “yes” answer and capture the “no” answer. So, for example, you’ll have two fields that both anchor on “physically disconnected”: one field that captures the “yes” checkbox, and then another field with an offsetX parameter that captures the “no” checkbox. See Nearest checkbox for the docs.

For #2, I’d recommend our computed field method called pickValues for situations like this. you’d use the checkbox or nearestCheckbox method to capture the true/false values for each checkbox as individual fields. Then you’d feed the IDs of those fields to the pickValues computed field method. You can use it to return all of the fields where yes (or no if you wanted) is selected. Here are the docs on that method.