Table of Contents
mcCgAccordion - Expand and collapse choice groups in a multiple choice question
The mcCgAccordion function expands and collapses choice groups in a multiple choice question. It automatically adjusts behavior for single and multi-select choice groups.
Here is a quick video demonstration:
Features include:
- Option to set start modes: collapsed, expanded, and auto
- Auto collapses and displays selected choice for single select choice groups
- Compatible with mcColumns and choiceGroupAnchorExclusive
This function is available for a reasonable fee. Contact TomG on the Qualtrics Community to learn more.
Set-up Instructions
Survey Header
Add the mcCgAccordion function to the survey header to make it available to any question in the survey. Go to Look & Feel → General → Header edit → and paste the provided mcCgAccordion function JS:
<script>/*Paste mcCgAccordion function JS here*/</script>
Alternatively, paste the mcCgAccordion function JS into a question's JS outside the existing Qualtrics functions to make it available to questions on the page.
Question Setup
Question Options
The requirements for the multiple choice question are:
- Format: List
- Alignment: Vertical
Choice Groups
Create choice groups and assign choices to the groups. Do NOT hide the choice group titles. Set other choice group options as needed.
Question JavaScript
Add JS to call the mcCgAccordion function to apply it to the multiple choice question as follows:
Qualtrics.SurveyEngine.addOnload(function() { mcCgAccordion(this); });
To override the default options, specify the desired options is the second function argument as an object. For example:
Qualtrics.SurveyEngine.addOnload(function() { mcCgAccordion(this,{start:"expand"}); });
Options
collapseText
collapseText is a string that specifies the text display to the right of the choice group label when a choice group is expanded.
Default: '^'
expandText
expandText is a string that specifies the text displayed to the right of the choice group label when a choice group is collapsed.
Default: '˅'
start
start is a string that specifies the start mode of the choice groups. There are three valid values:
- auto - expand the first unanswered choice group and collapse the others
- collapse - collapse all choice groups
- expand - expand all choice groups
Default: 'auto'