I want respondents to observe the outcome of a virtual coin flip. For example, I have two images pic_head and pic_tail, and I want the images to flip over a couple of times before it lands on the outcome. The coin flip starts automatically when the page loads and should stop after 2 or 3 secs.
Does anyone have a related js code for this that I could refer to?
Thanks!
Best answer by Tom_1842
I found a codepen by user Siva that I was able to put into Qualtrics.
To give it a try, first create the Embedded Data fields of "headsCount" and "tailsCount" and put them at the top of the Survey Flow.
Then create a Text/Graphic question and use the Rich Content Editor's HTML/Source view "<>" to update the question text with the below:
<divclass="container"><h2>Flip this coin!</h2><divid="coin"><divid="heads"class="heads"> </div><divid="tails"class="tails"> </div></div><buttonid="flip">Flip Coin</button><p>Heads: <spanid="headsCount">0</span> Tails: <spanid="tailsCount">0</span></p><p><spanid="status"> </span></p></div>
Next, add the below to the question's JavaScript in the OnReady section:
This is a unique idea, unfortunately I can’t assist with the css code to do this though. An alternative might be is if you can create an animated image or video & insert that into the survey instead, have two versions and then randomise which is shown. This would need you to have an animation of a coin flip, rather than a static image. You might be able to find something like this online though.