Resolving "unexpected token ILLEGAL" message in an autocomplete form-field question? | XM Community
Solved

Resolving "unexpected token ILLEGAL" message in an autocomplete form-field question?

  • 20 July 2021
  • 2 replies
  • 222 views

Thank you in advance to anyone who can help!
I'm assisting on round 2 of a project and we're trying to re-use a bit of JS code written in 2019 by someone who is no longer working on the project.
The question type is form-field, and respondents can enter up to 20 responses. We'd like to ensure that when respondents start typing, an option from a list of 800+ options starts to auto-complete - we want to reduce the amount of data clean up to do later on.
Our code looks like:
Qualtrics.SurveyEngine.addOnReady(function()
{
var autocomplete_services = [
"Example Option", 
"Example Option 2",
]

jQuery(# + this.questionId)
.find(".InputText")
.autocomplete({source:autocomplete_services})

});
When I try to apply this as javascript to the question (with our actual options between the [ ] brackets), I get an "Invalid Javascript! You cannot save until you fix all errors: Unexpected token ILLEGAL" message!
As mentioned we're trying to re-use this bit of code that was previously written, and I'm not familiar enough with JavaScript to figure out what's going wrong on my own. I feel like there's something really obvious I'm missing.
Any help is greatly appreciated; I couldn't find any similar questions by searching. Thank you in advance!

icon

Best answer by ahmedA 20 July 2021, 23:17

View original

2 replies

Userlevel 7
Badge +21

change # to "#"

Thank you so much, it worked!

Leave a Reply