Display logic in loop following randomized matrix | XM Community
Skip to main content

Hi!
Hope you can help me out! I'm quite new to Java so I'm quite stuck.
I'm trying to add display logic to a loop (Q4, ...) that goes over all choices/statements displayed in a previous matrix question (Q3). The matrix question contains 10+ choices/statements, of which a random set of 5 is displayed to respondents. Depending on which value was selected for each choice/statement of the matrix, a different set of questions should pop up in the loop.
So far I got the matrix question with the random set generator (Q3) and I set up a loop containing Q4, which should pop up for all statements from Q3 that were given a value of (let's say) 1 or 5. That part obviously needs some Java that I'm failing at. I got this:
Qualtrics.SurveyEngine.addOnload(function()
{
var_name = "${lm://Field/2}" + "_display_order"; //to keep track of which choice/statement is currently in the loop
Qualtrics.SurveyEngine.setEmbeddedData(var_name,"${lm://CurrentLoopNumber}");

no = getChoiceRecodeValue("Q3_" + "${lm://Field/2}"); //no idea what the choiceID should be :(

var x = document.getElementById("QID4");
x.style.display="none";
if (no == "7") {
            x.style.display="block"
        }
        else {
            x.style.display="none"
        }

});
I'd really appreciate any help! Thank you!

Be the first to reply!

Leave a Reply