Response summary - hide - question | XM Community
Skip to main content

I am showing response summary as user complete survey. This is Qualtrics generated. From this i want to hide one question or descriptive text which says “Click Submit button to finish survey”. How can I hide just this one descriptive text question from Qualtrics generated respnse summary

@Aggarwal Try to add this JavaScript to the question which contains the text: 

Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/

// Function to find element based on text
function findElementWithText(node, text) {
if (node.nodeType === Node.ELEMENT_NODE) {
// Check if the current element has the desired text
if (node.textContent.trim() === text) {
return node;
}

// Recursively search through child nodes
for (let child of node.childNodes) {
let result = findElementWithText(child, text);
if (result) {
return result;
}
}
}

return null;
}

// Check if the question is shown in the response summary
const responseSummaryElements = document.querySelectorAll('.ResponseSummaryQuestion.' + this.questionId);

responseSummaryElements.forEach((element) => {
// Find the element with the specific text
const targetElement = findElementWithText(element, 'Click Submit button to finish survey');

// If the element is found, hide it
if (targetElement) {
targetElement.style.display = 'none';
}
});
});

The JavaScript checks if the relevant question has style class ResponseSummaryQuestion which only questions have when they are shown in the response summary. For those question all the child elements are checked if they have the text specified in const targetElement. If such element is found, it’s hidden by changing the display style to ‘none’. 

If the text is a whole graphix/text question, I would suggest to better hide the whole question with some custom CSS: 

.ResponseSummaryQuestion.QID1 {
display: none;
}

QID1 would need to be replaced with your actual QID of the question. 

Alternatively to the CSS, you could use this JavaScript to hide the question only in the response summary: 

Qualtrics.SurveyEngine.addOnReady(function()
{
const element = document.getElementById(this.questionId);

// Check if the element is shown in the response summary
if (element && element.classList.contains('ResponseSummaryQuestion')) {
// Hide the element by setting its display style to 'none'
element.style.display = 'none';
} else {
element.style.display = 'block';
}
});

The JavaScript would have the advantage that the question ID is determined dynamically. 

This was my setup to test: 

In my response summary, the first question/text is hided: 

Disclaimer: The solution will need adjustments if you work with simple layout. 

Best
Christian


Leave a Reply