Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Automatically proceed to next question after selecting answer

  • Siem
  • Siem's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
7 years 2 weeks ago #149263 by Siem
I have a survey with a list with radio-buttons and I would like the user to proceed to next question after selecting answer.

I have found some javascript solutions on this forum such as this one:
Code:
<script type="text/javascript" charset="utf-8">  
  $(document).ready(function(){
 
    $('#question{QID} input.radio').click(function() {
      checkconditions($(this).attr('value'), $(this).attr('name'), $(this).attr('type'))
      $('#movenextbtn, #movesubmitbtn').trigger('click');
    });
  });
</script>

However I get this error when I implement (adding the code to "question.pstpl") it:
Code:
One or more mandatory questions have not been answered . Please answer this first to proceed !

I run the default template on version 2.63.0+170304

What can I do to make this work?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 2 weeks ago #149265 by tpartner
I just tested and it works fine for me with a single list-radio question on a page. Do you have other mandatory questions on that page?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 2 weeks ago #149267 by tpartner
Oh, wait, there's a conflict when clicking on the .label-clickable elements. Try this:

Code:
<script type="text/javascript" charset="utf-8">
  $(document).ready(function(){
 
    $('#question{QID} input.radio').click(function() {
      checkconditions($(this).attr('value'), $(this).attr('name'), $(this).attr('type'));
      $('#movenextbtn, #movesubmitbtn').trigger('click');
    });
 
    $('#question{QID} .label-clickable').unbind();
    $('#question{QID} .label-clickable').click(function() {
      $('#question{QID} input.radio').unbind();
      var input = $(this).parent().find('input.radio');
      $(input).trigger('click');
      checkconditions($(input).attr('value'), $(input).attr('name'), $(input).attr('type'));
      $('#movenextbtn, #movesubmitbtn').trigger('click');
    });
  });  
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: tomtom
The topic has been locked.
  • Siem
  • Siem's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
7 years 2 weeks ago #149291 by Siem
Many thanks, this solution works perfectly!
The topic has been locked.
More
6 years 6 months ago #158319 by hafees89
How if I wanna do for 1 question only? This 1 will automatically proceed to next question for every question right. How if 1 question only I wanna do? Mind to help? Thank you.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 6 months ago #158325 by DenisChenu
@tpartner : adding $(input).trigger('click'); trigger ('#question{QID} input.radio').click(function() , then it must work witout the 2 lines after ? No ?

/me must review framagit.org/SondagePro-LimeSurvey-plugi...assets/autosubmit.js

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
More
6 years 6 months ago - 6 years 6 months ago #158327 by hafees89
Let say I have 5 question all using radio button. But for the 1st question only I wanna use automatic next. It is possible? Kindly advice me on this. Thank you sir.

I'll review ur code sir.. Thank you again..
Last edit: 6 years 6 months ago by hafees89.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 6 months ago #158347 by tpartner
@DenisChenu, sure, maybe - that was just a quick fix.

@hafees89, are all radios on the same page?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
6 years 6 months ago #158353 by marektondryk
Code:
<script type="text/javascript" charset="utf-8">
  $(document).ready(function(){
 
    $('#question{QID} input.radio').click(function() {
      checkconditions($(this).attr('value'), $(this).attr('name'), $(this).attr('type'));
      $('#movenextbtn, #movesubmitbtn').trigger('click');
    });
 
    $('#question{QID} .label-clickable').unbind();
    $('#question{QID} .label-clickable').click(function() {
      $('#question{QID} input.radio').unbind();
      var input = $(this).parent().find('input.radio');
      $(input).trigger('click');
      checkconditions($(input).attr('value'), $(input).attr('name'), $(input).attr('type'));
      $('#movenextbtn, #movesubmitbtn').trigger('click');
    });
  });  
</script>

Where should I put this code?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 6 months ago #158357 by tpartner

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
6 years 6 months ago #158374 by marektondryk
Thanks Tony! :)
But how can I hide button NEXT on question pages?
The topic has been locked.
More
6 years 6 months ago - 6 years 6 months ago #158376 by hafees89
Yes, all radios on the same page.. Only wanna change for the 1st question using auto next..
Attachments:
Last edit: 6 years 6 months ago by hafees89.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose