Welcome to the LimeSurvey Community Forum

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

Change focus to next question on page

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 2 months ago #179985 by tpartner
Replied by tpartner on topic Change focus to next question on page
It works for me, what device and OS are you using?

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
4 years 2 weeks ago #195891 by matanzino
Replied by matanzino on topic Change focus to next question on page
Dear all,
The above posted code works fine for me, however, I would like to adapt the code so it also works for array questions. That is, after each answer in an array the focus moves to the next line in the array. The behaviour would be particularly useful for answering them on cell phones.
Can anyone help me in getting the correct scroll location? Unfortunately, I am not very familiar with js and CSS.
The topic has been locked.
More
4 years 2 weeks ago #195901 by matanzino
Replied by matanzino on topic Change focus to next question on page
With the help of a friend I got a solution that works fine for me:
Code:
<script type="text/javascript" charset="utf-8">
  $(document).ready(function(){
    $('#question{QID} input[type="radio"]').on('change', function(event) {
          var radioList = $(this).closest('.radio-list');
    $("html, body").animate({ scrollTop: radioList.next('.radio-list').offset().top-100}, 1000);
    return true;
    });
  });
</script>
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 2 weeks ago #195902 by tpartner
Replied by tpartner on topic Change focus to next question on page
This will work in an array. You may need to adjust the topMargin variable.

Code:
<script type="text/javascript" charset="utf-8">
  $(document).on('ready pjax:scriptcomplete',function(){
    $('#question{QID} input[type="radio"]').on('click', function() {
      var thisRow = $(this).closest('tr');
      if($(thisRow).next('tr').length > 0) {
 
        var topMargin = 100;
 
        $('html, body').animate(
          { scrollTop: $(thisRow).next('tr').offset().top-topMargin }, 
          1000
        );
      }
    });
    });
</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.

Lime-years ahead

Online-surveys for every purse and purpose