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
Page 1 / 1
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)
{
}
}
}
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)
{
}
}
}
> @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);
```
> 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);
```
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
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.