only accept first MCQ answer (without moving page) | XM Community
Question

only accept first MCQ answer (without moving page)

  • 16 August 2023
  • 3 replies
  • 28 views

Userlevel 1
Badge +1

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

Userlevel 5
Badge +8

if it’s first choice add the below code onLoad

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

 

Userlevel 1
Badge +1

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

Userlevel 5
Badge +12

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