Solved
How can I use embedded data with loop and merge+javascript?
I am implementing jQuery datepicker with merge and loop. I have implemented it to my requirement for one loop. But it requires me to set up an embedded field called 'date' but since I want to loop through (a max. of thirty times), it obviously overwrites the date field. Is there a way to suffix the loop index into my javascript code so that it stores it in different date variables depending on the loop number? I used the code provided in this question and I think this is where I need to make a change:
Qualtrics.SurveyEngine.addOnPageSubmit(function()
{
Qualtrics.SurveyEngine.setEmbeddedData( 'date', document.getElementById('datepicker').value );
});
Thanks!
Best answer by TomG
Yes, change it to:
```
Qualtrics.SurveyEngine.setEmbeddedData( "date${lm://CurrentLoopNumber}", document.getElementById("datepicker").value );
```
You'll have to add date1, date2, ..., dateX (where X is the maximum number of loops) as embedded data fields in your survey flow for them to be saved in the response data
View originalLeave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.