I found a solution in the community that counts the number of responses across several multiple choice questions on a page (see code below).
However when I change the alignment of the multiple choice question from the default vertical layout to column layout the solution no longer works.
Below is the code:
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;
if (num_chosen >= 2 && !this.querySelector(".q-checked")) {
this.click();
alert(
"Please select up to two choices only. Please remove a choice before proceeding."
);
}
}
I've tried adjusting the code. I've tried inspecting the question to try and work out what has changed in the question, but I can't work it out.
1) What do I need to update in the code to make it work when the multiple choice questions are in column layout?
2) How do I find this out in the future?
Thank you
Count Multiple Choice Responses when using Column Alignment
Sign up
Already have an account? Login
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login to the Community
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.

So, in the screenshot above, I clicked 5 items before it displayed the message.