Setting and Piping Embedded Data Using Only One Page Break | XM Community
Skip to main content

I have a survey with the following design:
Page 1: Ask two numerical questions
Page 2: Use Javascript to find the maximum answer from Page 1, set that value to an Embedded Data Value, following these steps on this post
Page 3: Use the updated embedded Data Value as piped text
Using three separate pages is the only way that I can figure out how to make this work. The first page break allows the numerical answers from Page 1 to be collected, before the Javascript on Page 2 uses the numbers. The second page break allows the updated embedded data from Page 2 to be processed, before that value is piped on Page 3. However, Page 2 is otherwise useless for the purposes of my survey, and results in a blank page that people have to click through.
Is there a way to insert a Javascript command in between the entering of the numeric answers on Page 1 and the piping of the updated embedded text on Page 3, without having to put the user through Page 2?

I think I have answered my own question:
Page 2 can be hidden and skipped over, while executing the Javascript, using the solution here.
However, I have an additional constraint, which is I want the survey user to be able to go back to Page 1, from Page 3, to change their answers, if needed. This solution won't let you do that, because you will get skipped back to Page 3 whenever you click the previous button on Page 3 to go to Page 2.
To solve this, at the top of the survey, I created an embedded data field named

next
, and set the initial value to "1".
On Page 2, I put the Javascript code that calculates the maximum number. Then I put the following code that automatically clicks next or previous, depending on the value of next:
if("${e://Field/next}"=="1")
{
jQuery("#"+this.questionId).hide();
this.clickNextButton();
Qualtrics.SurveyEngine.setEmbeddedData("next", "0");
}
else {
jQuery("#"+this.questionId).hide();
this.clickNextButton();
Qualtrics.SurveyEngine.setEmbeddedData("next", "0");
};
This way, when you first pass through Page 2, it skips to page 3. And when you press previous from Page 3, Page 2 skips back to Page 1, and so forth.


Leave a Reply