Predictive text? | XM Community
Skip to main content
Hi there!

I'm wondering if there is a way to add predictive text to a text entry question.

I.e.

What kind of car do you drive?

When the respondent begins typing A.. options like Audi, Aston Martin, Alfa Romeo pop up.
You can use Select2. When the respondent starts typing in the search box of the dropdown it will filter options to match their entry.
Just to expand on the answer from @dobra021...to use Select2 first call in the JS library and associated CSS via the header in the survey Look & Feel. Go to General and edit the Header. Switch it to HTML view and copy in the following code.



<link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css" rel="stylesheet" />

<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>

<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 set up your question as a Multiple Choice with either a dropdown or multi-select box that contains all the possible answers. Go to the Advanced Question Options and Add Javascript. In the AddOnReady section paste in the following JavaScript code:



`jQuery("#"+this.questionId+" select").select2({ placeholder:"Select an option" });`

Hey @GrayMatterThinking, can you please provide more detail your instructions for adding predictive text? I am using the survey builder and don't see the option to switch to HTML view in Look & Feel - General - Header.
I also don't see where to add Javascript in the Advanced Questions options....
Sorry for the newbie questions.
Screen Shot 2020-04-29 at 3.23.27 PM.pngScreen Shot 2020-04-29 at 3.23.59 PM.pngThanks!


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


kjohnston , I had the same problem. It turns out that advanced question editing is hidden and not available on trial accounts. It's hard to show POC to my business and why we should get this when I can't actually use the product...
Hidden Blocked Feature.png


Leave a Reply