text search in drop down list, contains string | XM Community
Solved

text search in drop down list, contains string

  • 19 March 2018
  • 4 replies
  • 356 views

Qualtrics has a nice search function when setting up display logic for a question. Let's say you are going to set display logic based on a question, and within the display logic box you search for the word "school". Qualtrics will display all questions which contain the string, "school", including questions that include the word "schooled". The "school" string does not have to be the first word in the question stem. All questions that have the word "school" anywhere in the question will be displayed for the programmer to select from. Nice.

Now let's say the respondent is given a question asking them to select the type of organization that they volunteer for. Since the list of organizations is very long (say 528 organization names), the respondent is presented with a multiple choice, drop down list question, and told that they can type a few letters in the box to help them narrow down the organization choices (instead of scrolling through the entire list of 528 organizations). But when the respondent types "school" , he or she is bounced to the choice that begins with "school". But really what the respondent needs is to be able to see all organization names that contain the string, "school", and then R can select the appropriate one. For some of these "school" choices, the string, "school", will be the first letters of the organization name, but for others, it will be the last letters of the organization name--or somewhere else in between. R needs to see all the "school" options.

Qualtrics support says this can't be done without a programming change, which will take, well, months at least. Since I asked for this years ago, I just figured it would be ready by now. But apparently there are better things for programmers to be doing--like making searches nice for survey programmers instead of respondents.

Does anyone know of a work-around?

Thanks.

--David
icon

Best answer by AnthonyR 19 March 2018, 23:01

View original

4 replies

Userlevel 7
Badge +7
Hi David, I would recommend integrating select2 to make this happen.
https://select2.org/

In the Look and feel menu, add the following to the source view of the header

<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script>

Then on the question you would like it added to, include the following in the JavaScript editor, inside the AddOnReady section:

var options = {
placeholder: 'Select an option'
};
jQuery("#"+this.questionId).find('select:first').select2({options});

As recommended by @TomG on this question
Perfect! Thanks for your expert help.
Userlevel 7
Badge +23
Somehow it stopped working for me...
Badge +1

Extremely useful. Thanks!

Leave a Reply