I intend to insert a random text into my question body. The random text could be either "positive" or "negative". Therefore,
(1) I create an embedded data named "tresult1" in the very beginning of the survey.
(2) I insert where I would like the random text inserted in the html view of the question body.
(3) add the follow javascript code in the question.
Qualtrics.SurveyEngine.addOnReady(function() {
var tresults = ["positive", "negative"];
var i = "${e://Field/tresult1}";
var tresult = tresults[i];
document.getElementById("random").innerHTML = tresult;
});
I found that the random text can be successfully inserted if I place only one of such questions on each page. But if I place more than one questions, then the second question and any questions following will not have the random text inserted. The only way to make the javascript work is to add page break. After add page break, each question will work as expected.
I would like to place two questions on each page. Does anyone know how to solve this problem? Thanks a lot!
Page 1 / 1
An element id has to be unique. To combine more than one on a page, use a class instead of an id.
https://www.qualtrics.com/community/discussion/comment/31383#Comment_31383Thank you for your prompt reply! It really helps!
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.