Predictive text? | XM Community
Skip to main content
Solved

Predictive text?

  • July 10, 2019
  • 5 replies
  • 106 views

Forum|alt.badge.img
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.

Best answer by GrayMatterThinking

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" });`

5 replies

dobra021
Level 4 ●●●●
Forum|alt.badge.img+37
  • Level 4 ●●●●
  • July 10, 2019
You can use Select2. When the respondent starts typing in the search box of the dropdown it will filter options to match their entry.

GrayMatterThinking
Level 2 ●●
Forum|alt.badge.img+4
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" });`

Forum|alt.badge.img+2
  • April 29, 2020

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!


  • August 19, 2020

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