Is there a way to use embedded data to logically pre-select a default choice in a multi-select MC qu | XM Community
Solved

Is there a way to use embedded data to logically pre-select a default choice in a multi-select MC qu

  • 11 October 2019
  • 5 replies
  • 397 views

Is there a way to use embedded data to logically pre-select a default choice in a multi-select MC question?

For example, here are things I know:

1. An embedded data field (e.g., 'source') is set based on information in a redirect URL.
2. There is a multi-select MC question (asking for respondent interests).
3. I know that based on the source collected form the URL that they are automatically interested in one of those (four) choices in the question.

The goals are:
1. To automatically select the known choice
2. To allow the respondent to select additional choices

Is this currently doable in Qualtrics today? What if I didn't want to allow them to de-select the known default choice?

Thanks,
Josh
icon

Best answer by TomG 11 October 2019, 18:05

View original

5 replies

Userlevel 7
Badge +27
Yes, it is doable with JavaScript. Pipe your embedded variable into the JS and apply some logic to select and disable the appropriate checkbox.
I have never used JavaScript before, but this what I came up with and seemed to work fine:

var edata = "${e://Field/source}";
var questionId = this.questionId;
var choiceIds = [1];

if (edata == 'Source')
{
for (var i=0; i < choiceIds.length; i++)
{
var choiceID = choiceIds[i];
try
{
this.setChoiceValue(choiceID,true);
}
catch(e)
{
}
}
}
Userlevel 7
Badge +27
> @willjota said:
> I have never used JavaScript before, but this what I came up with and seemed to work fine:
Congrats, but you kind of took the long way around. This would do the same thing:
```
if("${e://Field/source}" == "Source") this.setChoiceValue(1,true);
```
Badge +1

How would one get this to work on a multi-select in listbox view?

Would you use the same Javascript coding if you wanted to pipe in answer choices from a contact list? I know how to pipe in the answer choices we want to display, but I am having trouble getting the answer choices to be pre-selected also. Any assistance would be greatly appreciated and thanks!

Leave a Reply