Autocorrect by Select2 | XM Community
Skip to main content
Hello, I want to ask respondents to choose their colleagues (2 ~ 5 names) from the employee list (200+).



After I learned from many other forum posts and answers, now I found what helps me would be "select2".

I found some code examples and tried to put them in (Qualtrics.SurveyEngine.addOnReady) part of this page, but didn't work.

!



Also, I found some super users suggest to put some example codes to "header", but couldn't find where I should put them...



I'm so afraid of asking such newbie questions...

but It would be a great help if anyone could guide me to my next step.



1. What code should I put the question?

2. What does it mean to put some code on "header"?

3. How can I upload the whole employee list (200+ is too many to directly put in the line)?
Hi @Jun,

unfortunately, I don't understand your first question, but I think I can answer the next two.



> 2. What does it mean to put some code on "header"?

Here you can find instructions how to put anything to the header. If you want to put there a code it has to be inside HTML script tags otherwise it appears there as text.



> 3. How can I upload the whole employee list (200+ is too many to directly put in the line)?

You could store your list in a file which will be uploaded to the Qualtrics library. You can find an useful discussion about it here.



Note: If your code doesn't work, press F12 and check the console log. There should be some error which might give you a clue what's wrong. Another way is to comment whole code except few first lines and print your variables to the console log or alert them. In case this is OK, you can uncomment few next lines. (Just don't comment closing brackets of the Qualtrics function by mistake.)



Good luck with coding!
@fleb,

Thank you so much for your help!! 😃



## 1. Code



> unfortunately, I don't understand your first question, but I think I can answer the next two.



Sorry for my unclear question. From this select2 document, I found that the below code seems to help to implement multi-select boxes, but I'm wondering where I should put these two chanks of codes..





> In your HTML:

> ```

> <select class="js-example-basic-multiple" name="states[]" multiple="multiple">

> <option value="AL">Alabama</option>

> ...

> <option value="WY">Wyoming</option>

> </select>

> ```

> In your Javascript (external .js resource or <script> tag):

> ```

> $(document).ready(function() {

> $('.js-example-basic-multiple').select2();

> });

> ```

>



Is it right the second one (Javascript) should be put here?

```

Qualtrics.SurveyEngine.addOnReady(function()

{

/*Place your JavaScript here to run when the page is fully displayed*/

$('.js-example-basic-multiple').select2();

});

```



but I couldn't find where I should put the first one ("in your HTML").





## 2. Header

> > 2. What does it mean to put some code on "header"?

> Here you can find instructions how to put anything to the header. If you want to put there a code it has to be inside HTML script tags otherwise it appears there as text.



Thanks to you, I finally found the place I put sometihng to HTML header. Is it right?

!





## 3. Choice

Thank you so much! I am so happy to know that it is possible! Let me try how I can make it happen, once I implement the select2 itself to my questionnaure..





> > 3. How can I upload the whole employee list (200+ is too many to directly put in the line)?

> You could store your list in a file which will be uploaded to the Qualtrics library. You can find an useful discussion about it here.

>

> Note: If your code doesn't work, press F12 and check the console log. There should be some error which might give you a clue what's wrong. Another way is to comment whole code except few first lines and print your variables to the console log or alert them. In case this is OK, you can uncomment few next lines. (Just don't comment closing brackets of the Qualtrics function by mistake.)

Hi Jun
I'm interested in using Select2 in order to create a multi-select box like the one here.
Did you manage to find out how to create such a box? I'm reading several posts about it but none of them provide clear step-by-step information.
Best


Leave a Reply