Restrict checkbox responses based on answer to previous question

Hi there

I am trying to work out some logic for a checkbox question.

I need for you not to be able to select a certain response in a checkbox
question if the answer to a previous question is no.

First question does vessel have a tap yes/no
second question how is water drawn from this container?

Tap
Hands
utensil.

So I want to restrict being able to say tap if the vessel does not have a
tap.

I tried to use if statements but that wasn’t working and I also tried to
use the not function but that also didn’t work. I am not sure what I should
be including.

if(#form/group_sect_obs/list_vessel_obs/vessel_tap = ‘1’ and . >= 1,
true(), false())

not(selected(., ‘1’) and age_bfedstop = 0

Any assistance would be greatly appreciated.

I have now rearranged the expression to if(* question1*= ‘0’ and
selected(., ‘1’), false(), true()) and it seems to be working

··· On Thursday, January 12, 2017 at 11:58:47 PM UTC+11, Jessica Hall wrote: > > Hi there > > > I am trying to work out some logic for a checkbox question. > > I need for you not to be able to select a certain response in a checkbox > question if the answer to a previous question is no. > > First question does vessel have a tap yes/no > second question how is water drawn from this container? > > Tap > Hands > utensil. > > So I want to restrict being able to say tap if the vessel does not have a > tap. > > > I tried to use if statements but that wasn't working and I also tried to > use the not function but that also didn't work. I am not sure what I should > be including. > > if(#form/group_sect_obs/list_vessel_obs/vessel_tap = '1' and . >= 1, > true(), false()) > > not(selected(., ‘1') and age_bfedstop = 0 > > > Any assistance would be greatly appreciated. >

Glad to hear its working Jessica!

One minor suggestion - you actually don’t need the surrounding if()
statement but can use the condition itself directly, namely:

not(question1= ‘0’ and selected(., ‘1’))

Cheers,
Will

··· On Thu, Jan 12, 2017 at 3:30 PM, Jessica Hall wrote:

I have now rearranged the expression to if(* question1*= ‘0’ and
selected(., ‘1’), false(), true()) and it seems to be working

On Thursday, January 12, 2017 at 11:58:47 PM UTC+11, Jessica Hall wrote:

Hi there

I am trying to work out some logic for a checkbox question.

I need for you not to be able to select a certain response in a checkbox
question if the answer to a previous question is no.

First question does vessel have a tap yes/no
second question how is water drawn from this container?

Tap
Hands
utensil.

So I want to restrict being able to say tap if the vessel does not have a
tap.

I tried to use if statements but that wasn’t working and I also tried to
use the not function but that also didn’t work. I am not sure what I should
be including.

if(#form/group_sect_obs/list_vessel_obs/vessel_tap = ‘1’ and . >= 1,
true(), false())

not(selected(., ‘1’) and age_bfedstop = 0

Any assistance would be greatly appreciated.


You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Great thanks for the suggestion Will

··· On Friday, January 13, 2017 at 12:33:18 AM UTC+11, William Pride wrote: > > Glad to hear its working Jessica! > > One minor suggestion - you actually don't need the surrounding if() > statement but can use the condition itself directly, namely: > > not(*question1*= '0' and selected(., '1')) > > Cheers, > Will > > > > On Thu, Jan 12, 2017 at 3:30 PM, Jessica Hall <jhal...@gmail.com > wrote: > >> I have now rearranged the expression to if(* question1*= '0' and >> selected(., '1'), false(), true()) and it seems to be working >> >> >> On Thursday, January 12, 2017 at 11:58:47 PM UTC+11, Jessica Hall wrote: >>> >>> Hi there >>> >>> >>> I am trying to work out some logic for a checkbox question. >>> >>> I need for you not to be able to select a certain response in a checkbox >>> question if the answer to a previous question is no. >>> >>> First question does vessel have a tap yes/no >>> second question how is water drawn from this container? >>> >>> Tap >>> Hands >>> utensil. >>> >>> So I want to restrict being able to say tap if the vessel does not have >>> a tap. >>> >>> >>> I tried to use if statements but that wasn't working and I also tried to >>> use the not function but that also didn't work. I am not sure what I should >>> be including. >>> >>> if(#form/group_sect_obs/list_vessel_obs/vessel_tap = '1' and . >= 1, >>> true(), false()) >>> >>> not(selected(., ‘1') and age_bfedstop = 0 >>> >>> >>> Any assistance would be greatly appreciated. >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "commcare-users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to commcare-user...@googlegroups.com . >> For more options, visit https://groups.google.com/d/optout. >> > >