Thomas Gibbons Consulting Qualtrics Wiki

Contact TomG on Qualtrics Community

User Tools

Site Tools


sbsselectalphabetize

sbsSelectAlphabetize - Alphabetize selects (aka dropdowns) 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 all dropdowns or specific dropdown columns in a side-by-side

This function is available for a reasonable fee. Contact TomG on the Qualtrics Community to learn more.

To alphabetize choices in multiple choice questions on-the-fly, see mcAlphabetize.

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 (i.e., option values) 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. Choice ids should be listed in the order they should be displayed.

To identify choice ids (i.e., option values), preview the question and use the Inspect feature of your browser.

Default: [] (nothing anchored)

langs

langs is an object for mapping Qualtrics language codes to valid JavaScript locale languages for correct sorting. It is only needed if the Qualtrics language code doesn't resolve to valid JavaScript locale language code. Of the built-in Qualtrics languages, only ZH-S (Simplified Chinese) and ZH-T (Traditional Chinese) don't resolve, but they are included in the langs object by default.

If you have created your own language code, you made need to add your language to the langs object if it doesn't automatically resolve. A new language specification would look like langs:{"XX":"yy"}.

qlang

qlang is the Qualtrics language code string that should be used to do the alphabetization. By default, this is the current language of the survey.

Default: "${e://Field/Q_Langauge}"

select

select is the css selector for the selects to be alpabetize. By default all selects (dropdowns) in the Side-by-Side (SBS) will be alphabetized. To specify a specific SBS column add the column class before 'select'. For example to specify the first answer column use '.SBS1 select'.

Default: "select"

Qualtrics Wiki

sbsselectalphabetize.txt · Last modified: 2023/09/25 06:49 by admin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki