Randomize the position of next button | XM Community
Skip to main content

Hi!
I would like to place the next button of a Qualtrics survey in three positions (left, middle, right). The position must be constant for the same participant (e.g. for participant 1 always on the left), but should be randomized between participants (e.g. participant 2 on the right, and so on).
I have used the following JS code for individual questions (since I can only add JS for each question but not for the entire survey), but if I apply this to all individual questions the next button will appear in different locations for the same participant:
var Button = document.getElementById("NextButton");

var ButtonContainer = Button.parentNode;

if(Math.random() < 0.333){
ButtonContainer.style.textAlign = "left"
}else {
if (Math.random() < 0.5) {
ButtonContainer.style.textAlign = "center"
} else {
ButtonContainer.style.textAlign = "right"
}
}
Apparently, the only way to add custom code for the entire survey is via CSS (in Look & Feel settings), I'm aware I cannot implement if/else functions in CSS, thus I don't know what to do.
Any hint would be really appreciated! Thanks in advance!

Be the first to reply!

Leave a Reply