How to prompt all answers but one in a matrix table | XM Community
Skip to main content
Question

How to prompt all answers but one in a matrix table

  • January 20, 2025
  • 3 replies
  • 32 views

Forum|alt.badge.img+1

Hi Qualtrics community,

I’m designing a matrix table question where I want to prompt participants to answer any unanswered rows, but I want to exclude the last row "Other " from this prompt. 

Here are the specifics of my setup:

  • The matrix is a single-answer per row question.
  • The last row ("Other") includes a text entry box.
  • Participants should:
    1. Be prompted to answer any unanswered rows except for "Other."
    2. Always have the option to proceed even if some rows are unanswered (no forced responses)

Can anyone help with a JS skript oder other solutions? Costum validation seems to work only with forcing answers…

Thank you! (:  

 

3 replies

Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • 2028 replies
  • January 20, 2025

Please try this:

Qualtrics.SurveyEngine.addOnReady(function () {
	const quest = this;
	const qc = quest.getQuestionContainer();

	const allRows = Array.from(qc.querySelectorAll("tr.ChoiceRow"));
	const optionRows = allRows.filter((row) => !row.querySelector(".InputText"));

	const holder = document.querySelector(".Skin");
	function rrHandler(mutationsList) {
		mutationsList.forEach(() => {
			const rr = document.querySelector(".RequestResponse");
			if (rr) {
				rr.classList.remove("shown");
				const allChecked = optionRows.all((row) => !!row.querySelector(".q-checked"));
				if (allChecked) {
					// Don't show request response options if all rows without without input box have answers
					const allButtons = holder.querySelectorAll(".ErrorButtons button");
					allButtons[0].click();
				} else {
					// Show request response options if there are some unanswered rows
					rr.classList.add("shown");
				}
			}
		});
	}

	const observer = new MutationObserver(rrHandler);
	observer.observe(holder, { childList: true });

	// Hide the request response options initially
	document.body.insertAdjacentHTML("beforeend", "<style>.RequestResponse{opacity: 0;}.RequestResponse.shown{opacity: 1;}</style>");
});

 


Forum|alt.badge.img+1
  • Author
  • 2 replies
  • January 21, 2025

It works! Thank you so much, this is great! 


Forum|alt.badge.img+1
  • Author
  • 2 replies
  • January 21, 2025

I just tried my whole survey. Is it possible that the code messes with other questions? I receive no prompt for other questions any more even though I activated it in the requirements.


Leave a Reply