Scripting logic question

I have 5 multiple choice questions, and our users are required to select at least one answer from any of the questions. I want to create a required Note that will display if they do not answer any of the questions and will not display if any questions are answered.

The following script for the skip logic displays the Note initially, but it does not become hidden when a question is answered:

${HIV_AIDS} = ‘’ or ${Chronic_disease} = ‘’ or ${Mental_illness} = ‘’ or ${Injuries} = ‘’ or ${Diagnosis} = ‘’

Any suggestions?

1 Like

Hi @jblackman
You may need to use the count-selected option for this where you indicate

count-selected(${HIV_AIDS})>0 or count-selected(${Chronic_disease}) or count-selected(${Mental_illness}) or count-selected(${Injuries}) or count-selected(${Diagnosis})

What this does is that it counts the number of items selected in each question and checks that at least one item is selected.

Potential issue: Is any of the multiple choice skipped by default? If Yes, kindly indicate if it affects your script.


1 Like

Hi @jblackman,

Backing up with what @stephanealoo has advised you, you could also do it as outlined in the image below:

In the survey tab of the xlsform:

In the choices tab of the xlsform:
Image 2

Enketo view of your survey form (when non of the responses are selected):

Enketo view of your survey form (when at least one response is selected):

Reference xlsform:
Multiple Choice (conditional skip).xlsx (54.2 KB)

Have a great day!

Thanks. I had my logic backwards, using ‘any’ rather than ‘all’.

This can also be done through the KoBoToolbox interface:

Which gives the following script:
${STI_non_HIV_AIDS} = ‘’ and ${Chronic_disease} = ‘’ and ${Mental_illness} = ‘’ and ${Injuries} = ‘’ and ${Diagnosis} = ‘’