Pre-populate a text entry field from a multiple choice field | XM Community
Skip to main content

I have a multiple choice drop down field of site (Bath, Birmingham, Cardiff etc.)
In the same block as the next question I have a text entry field of participant ID. This is always in the format of S/nnn (where Bath site_code is 01 so S01/nnn)
Is it possible to pre-populate the participant ID text feild with the S/ part dependent on what site is selected in the previous drop down field?
I believe I could do it by putting the site in a different block and then creating embedded data that can be piped in as a default response but wondered if there's a way of doing it so I don't have to break up the block?

You can use JS attached your drop down question:
Qualtrics.SurveyEngine.addOnPageSubmit(function() {
var sites = {Bath:"01",Birmingham:"02",Cardiff:"03"};
var siteName = jQuery("#"+this.questionId+" select option:selected").text();
Qualtrics.SurveyEngine.setEmbeddedData("siteCode",sites[siteName]);
});
Then the default choice on your participant ID question would be:

S${e://Field/siteCode}/nnn


Leave a Reply