Custom code implemented to force accordion on desktop BUT it will not collapse once expanded | XM Community
Skip to main content

Context: I have a question that needed to be formatted as a collapsible list (industry expands to select sub-industry). Although drop down is clearly a better question type, my client has insisted on this format. As such, I have set up a block that has 1 matrix question for each industry (so each matrix has 1 statement) and the scales includes all the sub-industries (can vary from 1-5). Then, I added custom code to always force the matrix to display as an accordion style for desktop. However, the accordion must first display collapsed and then the respondent can choose to expand/collapse. I had a developer help me implement code so that the accordions are always first collapsed.
Issue: Once the accordion for that question is selected/expanded it will not collapse and remain expanded.
The developer I worked with said that it would be too much work to try to figure out how allow force the accordion questions to start collapsed and then allow for both expanding and collapsing. He also does not use Qualtrics so our collaboration is very much trial & error.
I know that for a matrix accordion the 1st statement is always first displayed expanded and the rest of the statements are collapsed. Is there a way to make the 1 statement (industry) behave as if it were the 2nd statement? This is assuming that it would then automatically display collapsed and there would be no problem collapsing and expanding.
This is the code for the first question in the block:
image.png



A more effective way to do this is NOT to use JavaScript. See this comment:
https://www.qualtrics.com/community/discussion/comment/9315#Comment_9315


Leave a Reply