Javascript to auto advance on click for single select box question | XM Community
Skip to main content
Question

Javascript to auto advance on click for single select box question


Hi all, I was wondering if it is possible to get a survey to advance to the next question upon clicking a selection from a select box. I've tried using the following code from Alex B in https://www.qualtrics.com/community/discussion/14/how-to-set-auto-advance-on-my-survey `Qualtrics.SurveyEngine.addOnload(function() { var that = this; this.questionclick = function(event,element){ if (element.type == 'radio') { that.clickNextButton(); } } });` But, this code only seems to work for regular Qualtrics questions and not select boxes. Please let me know! Thanks!

4 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5938 replies
  • August 5, 2019
Yes, add a change event handler to the select box.

mattyb513
Level 4 ●●●●
Forum|alt.badge.img+6
  • Level 4 ●●●●
  • 163 replies
  • August 6, 2019
```javascript Qualtrics.SurveyEngine.addOnReady(function() { var that = this; this.questionclick = function(event, element) { var qClass = element.classList[0]; if (qClass == 'Selection') { that.clickNextButton(); } } }); ```

  • Author
  • 1 reply
  • August 6, 2019
Hi TomG! Thanks for your response. I'm a little new to using Javascript and was hoping for just a bit more guidance on this. I tried using this code from: https://www.qualtrics.com/community/discussion/1088/javascript-or-jquery-change-event `Qualtrics.SurveyEngine.addOnReady(function() { var qid = this.questionId; this.disableNextButton(); this.hideNextButton(); var that = this; jQuery( "select[name='QR\\~"+qid+"']").change(function(){ if (jQuery( "select[name='QR\\~"+qid+"']").val() != '') { that.clickNextButton(); // move to the next page } } ); });` This code works, but it advances the following question automatically as well. Is there a way to prevent this? Thanks!

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5938 replies
  • August 6, 2019
> @hsteinmetz said: > This code works, but it advances the following question automatically as well. Is there a way to prevent this? I think that's because you're in preview mode. It is clicking Next for each frame.

Leave a Reply