I'm trying to make an easy way for respondents to find their job using jQuery Autocomplete, and have been able to get it to work using this excellent thread.
However the list I'm using for automcomplete suggestions contains about 7000 employments which creates problems of specificity. I want the respondent to be able to write "nurse orthop" and that the option "Orthopedic Nurse Practitioner" shows up. As of now, if words are written in the wrong order nothing shows up.
The survey will be in Swedish where long compund words are common, like in German. I want the spacebar to not signify word order but rather that jQuery uses the spacebar to broaden the search. For example we have a job title which is litterally "Flightcruisedirector" in one word. So I want the respondent to be able to write "direct cruise flight" and still be able to see the definition "Flightcruisedirector" come up as a suggestion. Which would mean that the spacebar would signify that any character can come before or after each of the respondents keywords and that the order of the words is not taken into account when autocomplete makes a list of options.
The second problem is a little simpler. I want the respondent to be able to scroll when several options are shown, as demonstrated here, but I can't get it to work.
Right now my code looks like this:
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
var textOptions = [
"3D-designer",
"Abonnemangsförsäljare",
"Abonnemangskontorist",
"Abonnentingenjör, vatten o. avlopp",
"Abonnentman",
"Account manager",
"Accounting controller",
"Ackompanjatör, klassisk musik",
"Ackompanjatör, populärmusik",
"[7000 other jobs]",
"Överåklagare",
];
jQuery('.InputText').autocomplete(
{source:textOptions,
minLength:3});
});
(I've also inserted this header as suggested in the thread mentioned above)
``<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>``
Thanks!
Daniel
Best answer by DanielE
View original