I’m trying to loop through various variables from a previous side by side question to include as values in a matrix question.
I’m using the code below. The commented out line works when there is just one value to include, but doesn’t work when I try and add loop using “/ + i + “. Is there syntax that does work/ another way of doing this?
n.b. I’m not using piping as there will be hundreds of values
for (var i = 1; i <= 3; i++) {
//var previousValue = "${q://QID182#1/ChoiceTextEntryValue/1/1}";
var previousValue = "${q://QID182#1/ChoiceTextEntryValue/1/" + i + "}";
jQuery("#QR\\~QID183\\~" + i + "\\~1\\~TEXT") // Target row i of new question
.val(previousValue) // Set the value from the previous question
.trigger("input") // Trigger an input event to update the field
.trigger("change"); // Trigger a change event to notify of the change
}
Thanks