Count Multiple Choice Response. | XM Community
Skip to main content
Question

Count Multiple Choice Response.

  • February 9, 2021
  • 1 reply
  • 71 views

Qualtrics 4.PNGI have 4 multiple choice questions in a block. What I want is: if user select more than 4 choices from 4 questions then it will give an error "Please select only 4 development area".
Scenario: User can leave any multiple choice question blank, User can select 4 choices from the same question. In total, out of 4 multiple choice question user could not able to choose more than 4 choice.

Thank you.

1 reply

Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • 2023 replies
  • February 9, 2021

You can use the following JS for it:
let all_checkboxes = document.querySelectorAll(".q-checkbox");
all_checkboxes.forEach((cb) => (cb.parentElement.onmousedown = selected_choices));


function selected_choices() {
    let num_chosen = document.querySelectorAll(".q-checkbox.q-checked").length;

    // Set the maximum number of choices you want to allow
    if (num_chosen >= 4 && !this.querySelector(".q-checked")) {
        this.click();
        alert(
            "You can not select more than 4 choices. Please unselect one to select another"
        );
    }
}


Leave a Reply