only accept first MCQ answer (without moving page) | XM Community
Skip to main content
Question

only accept first MCQ answer (without moving page)


Forum|alt.badge.img+1
  • Level 1 ●
  • 5 replies

Hi, 

 

I have a MCQ and I need to only accept the first answer to the question. However, I also need the participant to stay on the same page. Is this possible? e.g. disable the question after selection?

 

Any help/advice would be great, 

 

Thanks, 

3 replies

rgupta15
Level 4 ●●●●
Forum|alt.badge.img+8
  • Level 4 ●●●●
  • 92 replies
  • August 16, 2023

if it’s first choice add the below code onLoad

jQuery(‘input[type=”checkbox”]’).eq(0).prop(‘checked’,true)

 


Forum|alt.badge.img+1
  • Author
  • Level 1 ●
  • 5 replies
  • August 16, 2023

Hi Rahul, 

 

Thanks for taking the time to reply to my question, however this doesn’t seem to work. The code is accepted but when I run the survey, I am able to change the selection of the MCQ. 

 

Mark


Forum|alt.badge.img+20
  • QPN Level 5 ●●●●●
  • 290 replies
  • August 17, 2023

Hey @markw,
Please try the below code.
 

Qualtrics.SurveyEngine.addOnload(function() {
    var questionId = 'QID'; // Replace 'QID' with the actual question ID
    var selected = false;

    // Add a change event listener to the question's inputs
    jQuery('#'+questionId+' input').on('change', function() {
        if (!selected) {
            selected = true;
            jQuery('#'+questionId+' input:not(:checked)').prop('disabled', true);
        }
    });
});


Leave a Reply