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

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

  • October 11, 2019
  • 5 replies
  • 590 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

Best answer by TomG

Yes, it is doable with JavaScript. Pipe your embedded variable into the JS and apply some logic to select and disable the appropriate checkbox.

5 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 6084 replies
  • Answer
  • October 11, 2019
Yes, it is doable with JavaScript. Pipe your embedded variable into the JS and apply some logic to select and disable the appropriate checkbox.

  • Author
  • 1 reply
  • October 11, 2019
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) { } } }

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 6084 replies
  • October 11, 2019
> @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); ```

BrianF
Forum|alt.badge.img+1
  • 15 replies
  • April 25, 2021

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


  • 1 reply
  • September 8, 2021

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!