Millisecond Forums

Displaying a picture depending on the value a specific other variable has


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

By beccca - 8/5/2013

Dear all


I have the
following problem:


I created a
<picture> item (called ‘coinA&rsquoWink containing a picture of heads and a
picture of tails.


I created a
<values>-variable which chooses randomly between 1 and 2. I now want to
show the heads-picture if the <values>-variable (called ‘coin’ equals 1
and the tails picture if it equals 2.


But somehow
I can’t make it work. Do you have any ideas on that?


Below you
find the code I wrote.


Thanks a lot for your help.




<values >


/case = 0


/sentence="Previously you decided:
"


/coin = noreplace(1, 2)


</values>


 


 


<item coinA>


/ 1 = "heads.jpg"


/ 2 = "tails.jpg"


</item>


 


<picture coinA>


/ items = coinA


/ valign = bottom


/ position = (50%, 60%)


</picture>


 


 


**************************************************************************


**************************************************************************


 


<radiobuttons coinflip>


/ caption = "What does heads stand
for and what does tails stand for?"


/ options = ("HEADS = DECK A, TAILS = DECK C", "HEADS = DECK C, TAILS = DECK A")


/ fontstyle =("Arial", 1.75%)


</radiobuttons>


 


<surveypage coininstruction>


/ caption = Pleas assign heads and tails to either DECK A or DECK C."


/ questions = [1=coinflip]


/ fontstyle =("Arial", 1.75%)


/ showpagenumbers = false


/ showquestionnumbers = false


/ finishlabel = "CONTINUE"


/ showbackbutton = false


/ nextbuttonposition = (50, 85)


 


 


<item result>


/ 1 = "The machine has flipped the
coin for you and the result is:


</item>


 


<text result>


/ items =  result


/ select = 1


/ position = (50%, 10%)


/ fontstyle = ("Arial", 2%)


/ size = (80%, 30%)


/ hjustify = left


/ valign = top


</text>


 


 


<item meaning>


/1 =
"<%values.sentence%><%radiobuttons.coinflip.response%><%values.case%>


 


 


<%values.coin%> <%
picture.muenze3.itemcount %>"


</item>


 


<text meaning>


/ items = meaning


/ select = 1


/ position = (50%, 65%)


/ fontstyle = ("Arial", 2%)


/ size = (80%, 30%)


/ hjustify = left


/ valign = top


</text>


 


*************************************************************************


 


<trial result>


/ stimulusframes = [1=result, coinA,
meaning]


/ validresponse = (anyresponse)


/ inputdevice = keyboard


 


/ ontrialbegin = [if(values.coin == 1)
item.coinA.1 = "heads.jpg"]


/ ontrialbegin = [if(values.coin == 2)
item.coinA.2 = "tails.jpg"]


 


 


/ ontrialbegin =  [if(values.coin == 1 &&
radiobuttons.coinflip.response=="HEADS = DECK A, TAILS = DECK C")
values.case = "From now on you only take cards from DECK A]."


 


/ ontrialbegin = [if(values.coin == 2
&& radiobuttons.coinflip.response=="HEADS = DECK C, TAILS = DECK
A") values.case = "From now on you only take cards from DECK
A."]


 


/ ontrialbegin = [if(values.coin == 2
&& radiobuttons.coinflip.response=="HEAD = DECK A, TAILS = DECK
C") values.case = "From now on you only take cards form DECK
C."]


 


/ ontrialbegin = [if(values.coin == 1
&& radiobuttons.coinflip.response=="HEAD = DECK C, TAIL = DECK
A")  values.case = "From now on
you only take cards from DECK C."]


 


</trial>


 



 

By Dave - 8/5/2013

If you want your <picture> element's item to depend on the value, you need to use it in its /select attribute:


/ select = values.coin

By beccca - 8/5/2013

It works. Thank you so much Smile