thinkbot
thinkbot

Reputation: 51

using jQuery for autocomplete in Qualtrics

I am trying to implement auto-complete on an open-ended text question in Qualtrics using jQuery but I am not sure how to make it work.

At the moment, I tried using this jQuery example to add the javascript listed in the into the Qualtrics "Look & Feel --> Advanced"

<script>$.noConflict();</script>
<script>
  $(function() {
    var availableTags = [
      "ActionScript",
      "AppleScript",
      "Asp",
      "BASIC",
      "C",
      "C++",
      "Clojure",
      "COBOL",
      "ColdFusion",
      "Erlang",
      "Fortran",
      "Groovy",
      "Haskell",
      "Java",
      "JavaScript",
      "Lisp",
      "Perl",
      "PHP",
      "Python",
      "Ruby",
      "Scala",
      "Scheme"
    ];
    $( "#tags" ).autocomplete({
      source: availableTags
    });
  });
  </script>

I also added the following js to the body of the question, but it still does not work.

jQuery(function() {
    jQuery( "#QID15 .InputText" ).autocomplete({source: availableTags});
});

I am not very familiar with javascript and am struggling to figure out what goes where in Qualtrics. Any help or reference is would be greatly appreciated.

(In case you are wondering, I cannot simply implement this as a multiple choice type question in Qualtrics because there are hundreds of choices (i.e. list of departments in a school) and having an open-ended text field makes analyzing categories difficult.)

Upvotes: 0

Views: 1009

Answers (1)

p e p
p e p

Reputation: 6674

Have you included both jQuery.js as well as jQuery.ui.js via a script tag that appears prior to your above script declarations? Also, the first call to autocomplete has a selector selecting $('#tags') whereas the second selector is $('#QID15 .InputText'). Make sure you are using the correct selector.

Upvotes: 0

Related Questions