This is an old revision of the document!
Table of Contents
mcAlphabetize - Alphabetize choices on-the-fly in all languages
The mcAlphabetize function arranges multiple choice choices into alphabetical order on-the-fly. It is useful for translated surveys where you want the choices in alphabetical order for every language. It is also useful if you don't want to manually alphabetize each time you add a choice to a question.
Functionality includes:
- Works with vertical single answer, vertical multi-answer, dropdown list, select box and multi-select box
- Collates based on current language
- Supports anchoring of choices to the bottom of the list
mcAlphabetize currently does not support choice groups.
Set-up Instructions
Survey Header
To make the function available to all questions in the survey, copy the function to the Survey Header inside a script tag:
Add the mcAlphabetize 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 mcAlphabetize function JS:
<script>/*Paste mcAlphabetize function JS here*/</script>
Alternatively, paste the mcAlphabetize function JS into a question's JS outside the existing Qualtrics functions to make it available to questions on the page.
Multiple Choice Question
Question Settings
Any “Answers” setting is valid.
If “Answers” is set to either “Single Answer” or “Multiple Answer”, “Position” should be set to “Vertical”.
Question JavaScript
Add JS to call the mcColumns function to apply it to the Multiple Choice question as follows:
Qualtrics.SurveyEngine.addOnload(function() {
mcAlphabetize(this);
});
For anchored choices, use the anchors option to specify the choice ids as an array in the order the choices should be listed. For example:
Qualtrics.SurveyEngine.addOnload(function() {
mcAlphabetize(this,{anchors:[7,8]});
});
Options
anchors
anchors specifies the array of choice ids that should be anchored to the bottom of the list.
For multi-select boxes, the choice ids are specified as “QR~QIDxx~id” where 'QIDxx' is the QID of the question and 'id' is the choice id. For all other answer types, the choice id is a number or a number preceded by 'x' for carry forward questions.
To identify choice ids, preview the question and use the Inspect feature of your browser.
Default: [] (nothing anchored)
