Defining an item/text element with conditional logic using ontrialend


Author
Message
jfanderson
jfanderson
Partner Member (582 reputation)Partner Member (582 reputation)Partner Member (582 reputation)Partner Member (582 reputation)Partner Member (582 reputation)Partner Member (582 reputation)Partner Member (582 reputation)Partner Member (582 reputation)Partner Member (582 reputation)
Group: Forum Members
Posts: 5, Visits: 12
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!
Dave
Dave
Supreme Being (855K reputation)Supreme Being (855K reputation)Supreme Being (855K reputation)Supreme Being (855K reputation)Supreme Being (855K reputation)Supreme Being (855K reputation)Supreme Being (855K reputation)Supreme Being (855K reputation)Supreme Being (855K reputation)
Group: Administrators
Posts: 10K, Visits: 59K
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>
jfanderson
jfanderson
Partner Member (582 reputation)Partner Member (582 reputation)Partner Member (582 reputation)Partner Member (582 reputation)Partner Member (582 reputation)Partner Member (582 reputation)Partner Member (582 reputation)Partner Member (582 reputation)Partner Member (582 reputation)
Group: Forum Members
Posts: 5, Visits: 12
Thank you! That was the issue.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search