Welcome to the LimeSurvey Community Forum

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

Choosing an answer will automatically trigger the survey to go to the next page

  • Breezy
  • Breezy's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 6 months ago - 7 years 6 months ago #143315 by Breezy
I am creating a survey for a small pop-up window. I will have one question per page. To keep things simple, I would like the to survey to automatically go to the next page immediately after the answer is selected so I can hide the next button to save space. Is that doable? It would be similar to the Google consumer surveys (example: www.google.com/insights/consumersurveys/websat_example )
Last edit: 7 years 6 months ago by Breezy. Reason: Typo
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 6 months ago #143318 by Joffm
Hi, Breezy,
please have a look at this thread
www.limesurvey.org/de/foren/can-i-do-thi...ithout-clicking-next

I am also interested in a possibility to proceed automatically if the maximum length in a numerical input is reached.

Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: Breezy
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 6 months ago #143323 by tpartner

I am also interested in a possibility to proceed automatically if the maximum length in a numerical input is reached.

Try this in the source of a numeric question:

Code:
<script type="text/javascript" charset="utf-8">    
 
  $(document).ready(function(){
 
    var thisQuestion = $('#question{QID}');
 
    var maxLength = $('input[type="text"]:eq(0)', thisQuestion).attr('maxlength');
 
    $('input[type="text"]', thisQuestion).on('keyup', function(e) {
      if($(this).val().length == maxLength) {
        $('#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: Joffm
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 6 months ago #143324 by tpartner
...again, all sorts of caveats about the respondent not being able to fix errors with these auto-submit workarounds.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • Breezy
  • Breezy's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 6 months ago #143334 by Breezy
I tried using the code for the following link: www.limesurvey.org/de/foren/can-i-do-thi...ithout-clicking-next
Code:
<script type="text/javascript" charset="utf-8">
  $(document).ready(function(){
 
    $('#question{QID} input.radio').click(function() {
      if($('#movesubmitbtn').length > 0) {
        document.limesurvey.move.value = 'movesubmit';
      }
      else {
        document.limesurvey.move.value = 'movenext';
      }
      document.limesurvey.submit();
    });
  });
</script>

When I click a radio button, the page refreshes but the question is the same. It doesn't seem to go to the next page. Any idea on why this would be?

I tried the following but then it doesn't register the answer before it clicks next. If I click the answer twice then it works
Code:
<script type="text/javascript" charset="utf-8">
  $(document).ready(function(){
 
    $('#question{QID} input.radio').click(function() {
      $('#movenextbtn, #movesubmitbtn').trigger('click');
    });
  });
</script>
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 6 months ago #143342 by Joffm
Hi, Tony,

I use LS in this case to enter paper-pencil questionnaires.
Here everything is typed as numeric input, because this is much faster then using the mouse clicking radios or checkboxes.

I was looking for a solution like yours to avoid the use of the TAB key.
And most of the question are answered with a 1 digit code.

Thank you very much
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 6 months ago #143360 by tpartner

I tried the following but then it doesn't register the answer before it clicks next. If I click the answer twice then it works

LimeSurvey version? Template used?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • Breezy
  • Breezy's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 6 months ago #143384 by Breezy
I'm using Version 2.54.3+161014 and the standard newspaper template
The topic has been locked.
  • Breezy
  • Breezy's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 6 months ago - 7 years 6 months ago #143394 by Breezy
Here's a link to an example: [LINK REMOVED]
Last edit: 7 years 6 months ago by tpartner.
The topic has been locked.
  • Breezy
  • Breezy's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 6 months ago #143402 by Breezy
It works if I clicked directly on the radio button but not if I click on the label. I am debugging now so the link above will no longer work
The topic has been locked.
  • Breezy
  • Breezy's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 6 months ago - 7 years 6 months ago #143549 by Breezy
Through some debugging I was able to finally get it to work. I hesitated to post this because I am sure that this is a very indirect way to do it but at least it works for me. I needed to add 10 ms delay to the click. I added the following to template.js
Code:
 function nextQ() 
 {
     $('#movenextbtn, #movesubmitbtn').trigger('click');
 }
 function appendClick(robject) 
 {
     robject.attr("onclick",robject.attr("onclick") + ';setTimeout(nextQ, 10)');
 }
$(document).ready(function()
{
    appendClick($('.radio-list input.radio'))  
 
   ...   
Last edit: 7 years 6 months ago by Breezy.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose