- Posts: 12790
- Thank you received: 3940
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Autotab between fields
- Joffm
- Topic Author
- Offline
- LimeSurvey Community Team
Less
More
6 years 2 weeks ago #165342
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
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.
The length of the entry is recognized, but it does not proceed.
Any help is highly appreciated.
Joffm
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
Attachments:
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10634
- Thank you received: 3698
6 years 2 weeks ago #165345
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
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:
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
- Topic Author
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12790
- Thank you received: 3940
6 years 2 weeks ago #165346
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
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
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.