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

More
6 years 4 months ago #160914 by tomtom
Hi Tony. Thank you for your great jobs. I can apply it on each raido question now. But I would like to set a "YES/NO" question for participant who will go next page if only press "NO", since they will dropdown another ordinal question for "YES" answer. Thank you.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 4 months ago #160921 by Joffm
Hi, tomtom,

why don't you place the dropdown on the next page which is only displayed if the respondent clicked "Yes"?

Of course, the easy way.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
More
6 years 4 months ago #160924 by tomtom
Hello Joffm, thank you for your suggestion. Please refer to my attachments, there are two mandatory questions( 1 and 1.1).
Now I only can use the suggested code in question 1.1 to auto next. Sorry that I cannot how to describe, since if I add the code on both 1 and 1.1, the survey would pop up a mandatory problem while selecting the likert question. Please correct me, thank you so much.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 4 months ago #160930 by Joffm
Well,
if you think it to be absolutely necessary that the two questions appear on the same page it doesn't work.
But otherwise you can use the "normal" solution.

See attached sample.

File Attachment:

File Name: limesurvey...6579.lss
File Size:18 KB

Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: tomtom
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 4 months ago #160935 by tpartner
If you want both questions on the same page and only the first radio of the first question triggers the submit, place this script in the source of the first question:

Code:
<script type="text/javascript" charset="utf-8">
  $(document).ready(function(){
 
    $('#question{QID} .answer-item:eq(0) input.radio:eq(0)').click(function() {
      checkconditions($(this).attr('value'), $(this).attr('name'), $(this).attr('type'));
      $('#movenextbtn, #movesubmitbtn').trigger('click');
    });
 
    $('#question{QID} .answer-item:eq(0) .label-clickable').unbind();
    $('#question{QID} .answer-item:eq(0) .label-clickable').click(function() {
      $('#question{QID} .answer-item:eq(0) 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>

Sample survey attached:

File Attachment:

File Name: limesurvey...1-23.lss
File Size:16 KB

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.
More
6 years 4 months ago #160964 by tomtom
Hi Joffm and Tony. Thank you for your kindness, it is exactly what I want! If participant say NO, they will be auto passed to next, so for YES answers, participant should spend more time on thinking the likert scale answers. Great!!!
The topic has been locked.
More
6 years 1 month ago #164547 by csknfrt
Hello,

I tried with radio question but it didn't work. (LS 3.4.2+180223)


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>
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 1 month ago #164553 by tpartner
Try this for 3.4.x:
Code:
<script type="text/javascript" charset="utf-8">
  $(document).ready(function(){ 
    $('#question{QID} input[type="radio"]').on('click', function() {
      $('#ls-button-submit').trigger('click');
    });
  });  
</script>

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 1 month ago #164558 by csknfrt
Thank you tpartner it is working perfect! I have 2 question.

- May I use other question types like stars and slider?

- May I hide next, previous or send button on the question when i use this solition?
The topic has been locked.
More
6 years 1 month ago #164565 by csknfrt
I found answer to my second question but I still don't know answer of first question.
Code:
<script> 
$(document).ready(function() {
   $('#ls-button-previous').hide();
 });  
</script>
 
 
<script> 
$(document).ready(function() {
   $('#ls-button-submit').hide();
 });  
</script>


csknfrt wrote: Thank you tpartner it is working perfect! I have 2 question.

- May I use other question types like stars and slider?

- May I hide next, previous or send button on the question when i use this solition?

The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 1 month ago #164567 by tpartner
This will work in the 5 point choice (stars) type question:

Code:
<script type="text/javascript" charset="utf-8">
  $(document).on('ready pjax:scriptcomplete',function(){ 
    $('#question{QID} input[type="radio"]').on('change', function() {
      setTimeout(function() {
        $('#ls-button-submit').trigger('click');
      }, 250);
    });
  });  
</script>

This will work in sliders:

Code:
<script type="text/javascript" charset="utf-8">
  $(document).on('ready pjax:scriptcomplete',function(){ 
    $('#question{QID} input[type="text"]').on('slideStop', function(e){
      $('#ls-button-submit').trigger('click');
    });    
  });  
</script>


This will hide all navigation buttons:

Code:
<script type="text/javascript" charset="utf-8">
  $(document).on('ready pjax:scriptcomplete',function(){
    $('#navigator-container button').hide();    
  });  
</script>

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 1 month ago #164575 by csknfrt
Thank you tpartner for your support. it works perfect.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose