Target one multiple choice question and select radio button via jQuery | XM Community
Skip to main content
Solved

Target one multiple choice question and select radio button via jQuery


Forum|alt.badge.img+3

Hi There,

I'm almost there, but I just cannot figure out the last part. I want to get the value from the embedded data field and let it select a multiple choice answer option for ONLY question: QID1215751872. The issue is that the below input jQuery works, but it then fills all questions on the page with answer code 1.

I just want to target that one QID. The bottom two jQuery's seem to not work. How can I target one QID and select a certain choice id?
 

1Qualtrics.SurveyEngine.addOnload(function () {
2    var PullEmbData = Qualtrics.SurveyEngine.getEmbeddedData('Filter1');
3    console.log("Answer is:" + PullEmbData)
4    
5
6    if (PullEmbData = 'PulledValue') {
7        jQuery('input[choiceid=1]').prop('checked',true);
8    };
9    
10    //jQuery('#' + this.questionId + 'input[choiceid=1]').prop('checked',true); 
11    //jQuery('#QID1215751872 input[choiceid="1"]').prop('checked', true)
12
13});

Many thanks!

Best answer by TomG

Try this:

1Qualtrics.SurveyEngine.addOnload(function () {
2 var PullEmbData = Qualtrics.SurveyEngine.getEmbeddedData('Filter1');
3 console.log("Answer is:" + PullEmbData)
4
5
6 if (PullEmbData = 'PulledValue') {
7 jQuery(this.getQuestionContainer()).find('input[choiceid=1]').prop('checked',true);
8 };
9
10});

 

View original

2 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 6092 replies
  • Answer
  • June 13, 2024

Try this:

1Qualtrics.SurveyEngine.addOnload(function () {
2 var PullEmbData = Qualtrics.SurveyEngine.getEmbeddedData('Filter1');
3 console.log("Answer is:" + PullEmbData)
4
5
6 if (PullEmbData = 'PulledValue') {
7 jQuery(this.getQuestionContainer()).find('input[choiceid=1]').prop('checked',true);
8 };
9
10});

 


Forum|alt.badge.img+3
  • Author
  • Level 2 ●●
  • 16 replies
  • June 13, 2024

Legend! That works, many thanks! :)