How can I get an answer choice from a long list on a page to inform what is shown on a second page? | XM Community
Skip to main content

Simple, yet surprisingly stumping problem: I have a survey where participants select from a list of names in the form of “Title FirstName LastName” (e.g., Mr. John Doe). After their selection, I want the next page to show that data in the form of “Title LastName” (e.g., Mr. Doe). 
My normal method: set embedded data that assigns the second value (Mr. Doe) to a variable once the person selects the first value (Mr. John Doe), and then pipe through that embedded data to the second screen. 
Issues

  • There are a large number of names (328), which would make setting the embedded data for each choice a long process--and could Qualtrics even handle it??

  • The two pages are in the same block, so the embedded data cannot be set after the first page and before the second page--the second directly follows the first.

  • I can’t move the pages out of the same block, because that block is a loop and merge.

So, in sum: I have two pages, where I want the name chosen on the first page to be piped into the second page, but without the first name. They are in a loop and merge, so the first page must directly precede the second page in the same block. 
Any ideas?


I found a solution. For those interested, I got the selected name from the first page, fed it into Javascript, manipulated it such that I kept only title and last name, and then saved it as embedded data that was then piped into the next question. Worked like a charm! To work, though, the embedded data needs to be set at the beginning of the survey flow. Here's the code I used, in the JS for the first question:

Qualtrics.SurveyEngine.addOnPageSubmit(function() 
{
//code to retrieve the selected answer for multiple choice list
var name = jQuery("#"+this.questionId+" option:selected").text();
//did manipulations here to get 'title' and 'last_name' variables
var full_title = title + " " + last_name;
//created embedded data called 'teachername' to pipe into next question
Qualtrics.SurveyEngine.setEmbeddedData("teachername", full_title);
});


Leave a Reply