Welcome to the LimeSurvey Community Forum

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

Autotab between fields

  • Joffm
  • Joffm's Avatar Topic Author
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 7 months ago #165342 by Joffm
Autotab between fields was created by Joffm
Hi, all,
LS Version 2.72.4+171110

I would like to be able to autotab to the next field if the entry exceeds a certain length.
I have a lot of numerical entries which all are only one digit


In Stackoverflow I found the following:
And to be honest, I am not at all familiar with JavaScript.
Code:
<script type="text/javascript" charset="utf-8">
  $(document).ready(function(){
    $('input[type="text"]').keyup(function () {
      $this=$(this);
      if ($this.val().length >=1) {
        $this.next('input[type="text"]').focus();
      }
    });
  });
</script>

The length of the entry is recognized, but it does not proceed.

Any help is highly appreciated.

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
6 years 7 months ago #165345 by tpartner
Replied by tpartner on topic Autotab between fields
The problem is that .next() will only find direct siblings, whereas you are looking for a text input in the next sibling of the parent '.answer-item' element.

Try this:

Code:
<script type="text/javascript" charset="utf-8">
  $(document).ready(function(){
    $('#question{QID} input[type="text"]').keyup(function () {
      if ($(this).val().length >= 1) {
        $(this).closest('.answer-item').next('.answer-item').find('input[type="text"]').focus();
      }
    });
  });
</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.
  • Joffm
  • Joffm's Avatar Topic Author
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 7 months ago #165346 by Joffm
Replied by Joffm on topic Autotab between fields
Hi, Tony,
great - as usual.

I promise, one day I will learn about parents and siblings and so on.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose