Select multiple with relevant option

form-design

(Abrar) #1

What is the problem? Please be detailed.
I need to add a Select multiple question with relevant option.
Example : do you have any of these disease ? Diabetes, asthma , heart disease , non of the above.
And the next questions is ( do you take any medication for the above disease )
I want this questions to appear if one of the disease was selected

What ODK tool and version are you using? And on what device and operating system version?

Tablet
What steps can we take to reproduce the problem?
Tried to add relevant with , between option and didn't work

What you have you tried to fix the problem?

Show me please how to do it
Anything else we should know or have? If you have a test form or screenshots or logs, attach here.


(Souirji Abdelghani) #2

Hi @AbrarAlasmari,

Provided the answer to your first question is required, you can try puting under relevant column of your second question not(selected({YourMultipleSelectFieldName}, 'ValueofNonOfTheAboveChoice'))
So it will appear only if the operator chooses one of the listed diseases.


(Abrar) #3

Thanks ,
I tried it but it doesn't work.. it show error ..
Error at the start ( not)

Thanks
A.K.A


(Abrar) #4

Thanks a lot that was very helpful..
I added $ before the { and it works now

Many thanks
Abrar


(Souirji Abdelghani) #5

Hi @AbrarAlasmari,

You're right; I forgot the $ sign which should always be there before the first curly bracket when you refer to one of the variables.

Glad I could help.


#6

@Souirji_Abdelghani do you use the same method with select_one? If not what do you use with select_one


(Dr. Gareth S. Bestor) #7

Yes, technically you can use the same method - ie selected(${question},'value') - for a select_one, but because with a select_one there is only ever going to be a single result, it's a lot simple just to use ${question}='value'. Basically, with a select_one, you can check the (singular) result just as if it were a regular text question.

[if you want to know the gory details of how multiple selections are represented in XForms, and how the XPath selected() function checks for a specific value in such a result, just lemme know... :wink: ]