When to use


Author
Message
JL
JL
JL
posted 5 Years Ago HOT
Partner Member (888 reputation)Partner Member (888 reputation)Partner Member (888 reputation)Partner Member (888 reputation)Partner Member (888 reputation)Partner Member (888 reputation)Partner Member (888 reputation)Partner Member (888 reputation)Partner Member (888 reputation)
Group: Forum Members
Posts: 6, Visits: 17
Hi,

I understand that I need to use this syntax for combining text and properties / values and when defining the items attribute in a stimulis.

But, Do I also need to use this syntax when inserting a value within a textbox (survey) element or with a boolean expression as seen in the following example? 

<textbox Age>
/ Caption = “Age”
/ mask = integer
/ range (16,80)
/ value.ageans = <%textbox.Age.response%>
</textbox>

<dropdown Gender>
/ caption = "Select Gender"
/ options = ("female", "male")
If (<%dropdown.gender.caption>% == “female”)
{value.genderans=0}
Else
{value.genderans=1}
</dropdown>

Thanks!
Dave
Dave
Supreme Being (914K reputation)Supreme Being (914K reputation)Supreme Being (914K reputation)Supreme Being (914K reputation)Supreme Being (914K reputation)Supreme Being (914K reputation)Supreme Being (914K reputation)Supreme Being (914K reputation)Supreme Being (914K reputation)
Group: Administrators
Posts: 11K, Visits: 65K
I'm sorry, but this code does not make sense:

<dropdown Gender>
/ caption = "Select Gender"
/ options = ("female", "male")
If (<%dropdown.gender.caption>% == “female”)
{value.genderans=0}
Else
{value.genderans=1}
</dropdown>

#1: You don't want to access the dropdown's caption. You want to query its response.
#2: You cannot just put conditional logic in an element and expect it to work. Conditional logic needs to reside in event attributes (/ontrialbegin, ontrialend, etc.). A <dropdown> has no event attributes -- the <surveypage> the dropdown resides on has.

<surveypage mypage>
/ ontrialend = [if (dropdown.gender.response == "female") values.genderans = 0 else values.genderans = 1; ]
/ questions = [1=gender; ...]
...
</surveypage>

<dropdown Gender>
/ caption = "Select Gender"
/ options = ("female", "male")
</dropdown>
JL
JL
Partner Member (888 reputation)Partner Member (888 reputation)Partner Member (888 reputation)Partner Member (888 reputation)Partner Member (888 reputation)Partner Member (888 reputation)Partner Member (888 reputation)Partner Member (888 reputation)Partner Member (888 reputation)
Group: Forum Members
Posts: 6, Visits: 17
Thanks!

One more question regarding the above example:

/ value.ageans = textbox.Age.response

If i insert this line of code into a <surveypage> could I use the the value extracted from the textbox.age.response as an integer? If not, how is it possible to get the age as an integer so it can be used for mathematical expressions later on?



Dave
Dave
Supreme Being (914K reputation)Supreme Being (914K reputation)Supreme Being (914K reputation)Supreme Being (914K reputation)Supreme Being (914K reputation)Supreme Being (914K reputation)Supreme Being (914K reputation)Supreme Being (914K reputation)Supreme Being (914K reputation)
Group: Administrators
Posts: 11K, Visits: 65K
> / value.ageans = textbox.Age.response

This line is not valid syntax. If you "insert this line of code into a <surveypage>", it will not do anything. Just like with the dropdown, what you want is

<surveypage mypage>
/ ontrialend = [if (dropdown.gender.response == "female") values.genderans = 0 else values.genderans = 1; ]
/ ontrialend = [values.ageans = textbox.Age.response]
/ questions = [1=gender; 2=age]
...
</surveypage>



JL
JL
Partner Member (888 reputation)Partner Member (888 reputation)Partner Member (888 reputation)Partner Member (888 reputation)Partner Member (888 reputation)Partner Member (888 reputation)Partner Member (888 reputation)Partner Member (888 reputation)Partner Member (888 reputation)
Group: Forum Members
Posts: 6, Visits: 17
Ok. Just to make sure: A value that I define can only be updated as part of an event attribute and never as a standalone command line like I wrote above?

Dave
Dave
Supreme Being (914K reputation)Supreme Being (914K reputation)Supreme Being (914K reputation)Supreme Being (914K reputation)Supreme Being (914K reputation)Supreme Being (914K reputation)Supreme Being (914K reputation)Supreme Being (914K reputation)Supreme Being (914K reputation)
Group: Administrators
Posts: 11K, Visits: 65K
Yes.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search