Using Select2 in Drill Down Questions | Experience Community
Skip to main content
Solved

Using Select2 in Drill Down Questions

  • Aug 12, 2019 3:49 PM UTC
  • 2 replies
  • 187 views

jflowers1
Level 4 ●●●●
Forum|alt.badge.img+36
I have a drill down question in which I would like respondents to have the ability to start typing text and pull up matching answer choices to select from. I've seen other posts mention that using Select2 allows for this kind of functionality (I am a novice when it comes to using JavaScript). However, when I enter the following into the JavaScript for the question the search box only appears for the first item in the drill down and not the second. Any suggestions? var options = { placeholder: 'Select an option' }; jQuery("#"+this.questionId).find('select:first').select2({options});

Best answer by TomG

select:first only returns the first select. If you remove :first it will return all the selects.
View original

2 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • Answer
  • Aug 12, 2019 3:52 PM UTC
select:first only returns the first select. If you remove :first it will return all the selects.

jflowers1
Level 4 ●●●●
Forum|alt.badge.img+36
  • Author
  • Level 4 ●●●●
  • Aug 12, 2019 4:03 PM UTC
Great, thank you! That worked!