Setting more than one embedded data variable using Javascript

sarasermsaraserm PhiladelphiaCommunity Member Qubie ✭

Setting more than one embedded data variable using Javascript

I've been trying to set embedded data from a loop and merge function. There are three fields in the loop and merge and I am trying to have all three set to three different variables. I am using the same code for all three, but only field 1 is setting. All of the embedded data variables I want to fill are labeled and empty at the top of the survey so that's not the problem. See code below:

Qualtrics.SurveyEngine.addOnload(function()
{
/Place your JavaScript here to run when the page loads/

});/Place Your Javascript Below This Line/
var questionText = "${lm://Field/1}"; // "${lm://Field/1}" will actually evaluate to
//whatever is Field 1 in the current Loop & Merge loop.
// You can do this with embedded data too, as seen in the next line
var order = "${e://Field/min_40}" + questionText; // gets the value of the embedded data
// field "preorder", concatenates the current loop's identifier to it,
//and stores that as a variable
Qualtrics.SurveyEngine.setEmbeddedData('min_40', order); // updates the
//embeddeddata field "preorder" to be our order variable, which has the current loop's
//identifier attached, effectively constructing a string of numbers representing the order

Qualtrics.SurveyEngine.addOnload(function()
{
/Place your JavaScript here to run when the page loads/

});/Place Your Javascript Below This Line/
var questionText = "${lm://Field3}"; // "${lm://Field/1}" will actually evaluate to
//whatever is Field 1 in the current Loop & Merge loop.
// You can do this with embedded data too, as seen in the next line
var order = "${e://Field/tot_seats_40}" + questionText; // gets the value of the embedded data
// field "preorder", concatenates the current loop's identifier to it,
//and stores that as a variable
Qualtrics.SurveyEngine.setEmbeddedData('tot_seats_40', order); // updates the
//embeddeddata field "preorder" to be our order variable, which has the current loop's
//identifier attached, effectively constructing a string of numbers representing the order

Qualtrics.SurveyEngine.addOnload(function()
{
/Place your JavaScript here to run when the page loads/

});/Place Your Javascript Below This Line/
var questionText = "${lm://Field2}"; // "${lm://Field/1}" will actually evaluate to
//whatever is Field 1 in the current Loop & Merge loop.
// You can do this with embedded data too, as seen in the next line
var order = "${e://Field/inverse_40}" + questionText; // gets the value of the embedded data
// field "preorder", concatenates the current loop's identifier to it,
//and stores that as a variable
Qualtrics.SurveyEngine.setEmbeddedData('inverse_40', order); // updates the
//embeddeddata field "preorder" to be our order variable, which has the current loop's
//identifier attached, effectively constructing a string of numbers representing the order

Answers

  • sarasermsaraserm PhiladelphiaCommunity Member Qubie ✭

    I figured it out. I was missing a "/"

Sign In to Comment