Hello,
I was hoping that I could get some help modifying some JS, so that it can work within a ‘Loop & Merge’ block.
The script below works for a standard question, where the response from QID1 is used to determine which options will be hidden.
I am now wanting to embed these two questions within a looped block (i.e. using ‘Loop & Merge’), but have run into the problem where the initial reference to the selection from QID1 is no longer working, as there is now a loop count being applied to the question ID. Accordingly, I need to find a way to append the loop number to the reference of QID1, so that this code always applies to the question that directly preceded it (i.e. the one that is in the same loop).
Qualtrics.SurveyEngine.addOnload(function() {
var x = "${q://QID1/ChoiceGroup/SelectedChoices}";
if (x === "Brand1") {jQuery("#" + this.questionId + "inputdchoiceid='3']").closest("li").hide();}
else if (x === "Brand2") {jQuery("#" + this.questionId + "inputdchoiceid='6']").closest("li").hide();}
});
I am thinking that I need to apply "${lm://CurrentLoopNumber}" somewhere in the ‘var x = "${q://QID1/ChoiceGroup/SelectedChoices}"’ working, but I don’t know what the right syntax would be to achieve this. Can anyone assist?