====== formSelects - Convert form fields to dropdowns without custom JavaScript ======
The **formSelects** function converts one or more text form fields into selects (aka dropdowns) or searchable selects. The select options (aka choices) are defined using html in the choice text and question text, so no custom JavaScript is required...just call the **formSelects** function and that's it!
Features include:
* All configuration done using html - no custom JavaScript needed!
* Optional searchable selects using [[https://select2.org/getting-started/basic-usage|select2]]
* Optional dynamic option creation using select2
* Supports multi-selects
* Supports back button - even when dynamic options are created
* Supports default choices
* Translation friendly
* Supports "New Survey Experience" (aka Simple layout)!
Here is a quick video demonstration:\\
{{ ::formSelects.mp4?770 |formSelects Demonstration}}
This function is available for a reasonable fee. Contact **[[https://community.qualtrics.com/inbox/conversation?with=373|TomG]]** on the Qualtrics Community to learn more.
===== Set-up Instructions =====
==== Survey Header ====
=== Add select2 (if applicable) ===
If you wish to use searchable selects add the select2 stylesheet and library to the survey header. Go to Look & Feel -> General -> Header edit -> {{::icon_source.jpg?20|}} and paste:
=== Add jQuery (only if using New Survey Experience) ===
Alternatively, paste the formSelects 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 formSelects function to apply it to a form question as follows:
Qualtrics.SurveyEngine.addOnload(function() {
formSelects(this);
});
==== QuestionText Select HTML ====
In ''HTML View'' mode, add the html for the select(s). Each select should be assigned a unique class name that will be referenced in the corresponding **[[formselects#choice_label_html|Choice Label HTML]]**. To make a select a multi-select add the attribute ''multiple=%%"multiple"%%'' to the ''