Millisecond Forums

problem with branching

https://forums.millisecond.com/Topic17582.aspx

By vz29 - 11/2/2015

I'd like to use branching in the survey pages (if yes, go to question x, and if no, go to question y), but am not able to get it to work. Here's the syntax:


<surveypage demographics2>
/ caption = "Please answer the following demographic questions (continued)"
/ questions = [1=senseofsmell; 2=headinjuries]
/ branch = [if (radiobuttons.headinjuries.response = 1) surveypage.demographics2b]
/ branch = [if (radiobuttons.headinjuries.response = 0) surveypage.demographics3]
</surveypage>

<surveypage demographics2b>
/ caption = "Please answer the following demographic questions (continued)"
/ questions = [1=headinjuriescheck; 2 = headinjuries_date]
</surveypage>

<surveypage demographics3>
/ caption = "Please answer the following demographic questions (continued)"
/ questions = [1=health; 2=sinus]
/ branch = [if (radiobuttons.health.response = 1) surveypage.demographics3b]
/ branch = [if (radiobuttons.health.response = 0) surveypage.demographics4]


<radiobuttons headinjuries>
/ caption = "Have you ever had any head or facial injuries?"
/ options = ("Yes", "No")
/ optionvalues = ("1", "0")
/ orientation = horizontal
/ required = false
</radiobuttons>

<checkboxes headinjuriescheck>
/ caption = "Please indicate your head/facial injuries. (Select ALL that apply)"
/ options = ("Head Injury", "Facial Injury", "Concussion", "Loss of consciousness associated with head injury", "Amnesia/memory loss due to head injury")
</checkboxes>

<textbox headinjuries_date>
/ caption = "When did your head/facial injuries occur. Please specify the date(s) of their occurrence."
/ required = false
</textbox>

<radiobuttons health>
/ caption = "Are you currently healthy?"
/ options = ("Yes", "No")
/ optionvalues = ("1", "0")
/ orientation = horizontal
/ required = false
</radiobuttons>

<textbox healthfill>
/ caption = "Please elaborate on any current health problems you are having."
/ required = false
</textbox>

<checkboxes sinus>
/ caption = "Stuffy nose, allergies, sinus infections, and other similar symptoms can interfere with your ability to accurately identify scents. Please let us know if you are currently experiencing any of these symptoms. Check all options that apply."
/ options = ("Stuffy Nose", "Allergies", "Sinus Infection", "Sore Throat", "Congestion", "None of the above")
/ required = false
</checkboxes>

By Dave - 11/2/2015

<surveypage demographics2>
/ caption = "Please answer the following demographic questions (continued)"
/ questions = [1=headinjuries]
/ branch = [if (radiobuttons.headinjuries.response = 1) surveypage.demographics2b]
/ branch = [if (radiobuttons.headinjuries.response = 0) surveypage.demographics3]
</surveypage>

'=' is the assignment operator. '==' is the comparison / logical operator. You need to use the latter. You want to do a *logical* comparison, i.e. something that evaluates to either 'true' or 'false', not assign a value to a variable.

<surveypage demographics2>
/ caption = "Please answer the following demographic questions (continued)"
/ questions = [1=headinjuries]
/ branch = [if (radiobuttons.headinjuries.response == 1) surveypage.demographics2b]
/ branch = [if (radiobuttons.headinjuries.response == 0) surveypage.demographics3]
</surveypage>