Millisecond Forums

Defining an item/text element with conditional logic using ontrialend

https://www.millisecond.com/forums/Topic16787.aspx

By jfanderson - 7/23/2015

Hello,

I'm trying to define a name to be presented later to participants which will depend on their gender (provided in a dropdown response). The item and text elements do end up defined, but they aren't based on the logic and instead simply go with the first definition listed. Specifically, using the following:

<survey demographics>
/ pages = [1=demographics1; 2=demographics2]
/ itemspacing = 20px
/ showpagenumbers = false
/ ontrialend = [if (dropdown.sex.response = "female") item.ambigscentarget.item = "Maria"; if (dropdown.sex.response = "male") item.ambigscentarget.item = "Thomas"]
</survey>

<text ambigscentarget>
/ numitems = 1
/ items = ambigscentarget
/ select = noreplace
</text>

<item ambigscentarget>
</item>

ambigscentarget is always defined as "Maria" regardless of the participant's sex.

Any thoughts on how to adjust the logic to make things work?

Thanks in advance!
By Dave - 7/23/2015

You are using the wrong operator in your conditionals. '=' is the *assignment* operator (set a variable to the specified values), '==' is the comparison operator (evaluate equality between left side and right side; return either true or false). You need the latter:

<survey demographics>
/ showbackbutton = false
/ pages = [1=demographics1; 2=demographics2]
/ itemspacing = 20px
/ showpagenumbers = false
/ ontrialend = [if (dropdown.sex.response == "female") item.ambigscentarget.item = "Maria"; if (dropdown.sex.response == "male") item.ambigscentarget.item = "Thomas"]
</survey>

<surveypage demographics1>
/ questions = [1=sex]
</surveypage>

<surveypage demographics2>
/ stimulusframes = [1=ambigscentarget]
</surveypage>

<dropdown sex>
/ options = ("female", "male")
</dropdown>

<text ambigscentarget>
/ numitems = 1
/ items = ambigscentarget
/ select = noreplace
</text>

<item ambigscentarget>
</item>
By jfanderson - 7/24/2015

Thank you! That was the issue.