This is an old revision of the document!
Table of Contents
sbsSelectAlphabetize - Alphabetize selects (aka dropsdowns) within a Side-by-Side on-the-fly
The sbsSelectAlphabetize function arranges choices with side-by-side selects (aka dropdowns) 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 dropdown choice within a side-by-side.
Functionality includes:
- Alphabetizes based on current language
- Supports anchoring of choices to the bottom of the list
- Can be used on any dropdown column in a side-by-side
This function is available for a reasonable fee. Contact TomG on the Qualtrics Community to learn more.
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 sbsSelectAlphabetize 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 sbsSelectAlphabetize function JS:
<script>/*Paste sbsSelectAlphabetize function JS here*/</script>
Alternatively, paste the sbsSelectAlphabetize function JS into a question's JS outside the existing Qualtrics functions to make it available to questions on the page.
Question JavaScript
Add JS to call the sbsSelectAlphabetize function to apply it to the Side-by-Side question as follows:
Qualtrics.SurveyEngine.addOnload(function() {
sbsSelectAlphabetize(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() {
sbsSelectAlphabetize(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)
lang
Default: "${e://Field/Q_Langauge}"
select
Default: “.SBS1 select”
