Hello, I am somewhat new to Qualtrics and JavaScript. I have been trying to create a "for loop" to iterate over the fields in Loop and Merge and form a string with them. I am using a "for loop" because in the questions I have use a different number of fields.
I can get the information in the loop and merge fields if I do it manually like below.
var sentence = "${lm://Field/1}" + " " + "${lm://Field/2}" + " " + .... + "${lm://Field/10}";
alert('Original sentence ---> ' + sentence);
However, I want to do it with a "for loop" to iterate over the value saved in each field by accessing it by their number. Is this possible? I have been trying different things but I can't figure out how to use variables within template strings in Qualtrics.
var sentence = "";
for(i=0; i<10; i++)
{
var words = "${lm://Field/" + (i+1).toString() +"}";
sentence = sentence + " " + words;
}
alert('Original sentence ---> ' + sentence);
Any ides?
Miguel Santin
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.