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


Displaying a picture depending on the value a specific other variable...
Author
Message
beccca
beccca
Distinguished Member (3.2K reputation)Distinguished Member (3.2K reputation)Distinguished Member (3.2K reputation)Distinguished Member (3.2K reputation)Distinguished Member (3.2K reputation)Distinguished Member (3.2K reputation)Distinguished Member (3.2K reputation)Distinguished Member (3.2K reputation)Distinguished Member (3.2K reputation)
Group: Forum Members
Posts: 13, Visits: 11

Dear all


I have the
following problem:


I created a
<picture> item (called ‘coinA’) 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>


 



 


Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K

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


beccca
beccca
Distinguished Member (3.2K reputation)Distinguished Member (3.2K reputation)Distinguished Member (3.2K reputation)Distinguished Member (3.2K reputation)Distinguished Member (3.2K reputation)Distinguished Member (3.2K reputation)Distinguished Member (3.2K reputation)Distinguished Member (3.2K reputation)Distinguished Member (3.2K reputation)
Group: Forum Members
Posts: 13, Visits: 11

It works. Thank you so much :)


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search