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!
Page 1 / 1
Yes, add a change event handler to the select box.
```javascript
Qualtrics.SurveyEngine.addOnReady(function() {
var that = this;
this.questionclick = function(event, element) {
var qClass = element.classList[0];
if (qClass == 'Selection') {
that.clickNextButton();
}
}
});
```
Qualtrics.SurveyEngine.addOnReady(function() {
var that = this;
this.questionclick = function(event, element) {
var qClass = element.classList[0];
if (qClass == 'Selection') {
that.clickNextButton();
}
}
});
```
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!
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!
> @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.
> 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
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.