Your LimeSurvey version: 6.4.12
Hello!
I'm in the process of setting up an initial assignment for participants, giving each either a 0 or 1. This will dictate which link opens in fullscreen upon pressing a button. (In my context, these correspond to Game Version 1 or Game Version 2, in this example Bing & Google).
I thought this would be the most efficient way to get balanced a 50/50 chance for both links.I've managed to implement this successfully using the code provided below. However, I'm now interested in storing the assigned number (either 0 or 1) to track this in the final responses.I've tried to set it as an answer to a follow-up question, but can't get it to work.
What steps should I take next, or is there a more effective approach to address my requirement?
relevant code:
Code:
<p>Random Number:</p>
<p id="randomValue"> </p>
<script>
var randomValue = rand(0, 1);
document.getElementById("randomValue").innerText = "Zufallszahl: " + randomValue;
function openFullscreenPopup(url) {
var width = screen.width;
var height = screen.height;
var popupWindow = window.open(url, 'popupWindow', 'width=' + width + ', height=' + height + ', left=0, top=0');
if (window.focus) {
popupWindow.focus();
}
return false;
}
function openVersion() {
var gameVersion = (randomValue < 0.5) ? 'https://www.bing.com' : 'https://www.google.com';
openFullscreenPopup(gameVersion);
}
</script>
<button class="my-button" onclick="openVersion(); return false;">Open in Fullscreen</button>