- Posts: 77
- Thank you received: 4
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
How to auto-advance to the next question in Version 3
- bruce78
- Topic Author
- Offline
- Senior Member
Less
More
6 years 1 month ago #164656
by bruce78
How to auto-advance to the next question in Version 3 was created by bruce78
In version 2, the following script would hide the 'Next' button and automatically load the next question once an answer was clicked. However, in version 3, this behaviour no longer works...
Does anyone know how I can update the javascript below such that drop down and radio button questions auto-advance?
Does anyone know how I can update the javascript below such that drop down and radio button questions auto-advance?
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ $('tr.radio-list input.radio').bind('click', function () { var thisArray = $(this).closest('table'); if($('input.radio:checked', thisArray).length == $('tr.radio-list', thisArray).length) { $("#movenextbtn,#movesubmitbtn").delay(1).click(); } }); $(".list-dropdown select").change(function(){ if($(this).val()!="" && $(this).val()!="-oth-"){ $("#movenextbtn,#movesubmitbtn").delay(1).click(); } }); $('#movenextbtn, #movesubmitbtn').hide(); }); </script>
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12888
- Thank you received: 3965
6 years 1 month ago #164657
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic How to auto-advance to the next question in Version 3
Hi, bruce,
in version 3. the "#movenextbtn,#movesubmitbtn" have other IDs.
Now it is "#ls-button-submit"
Check by using a webdeveloper tool.
Joffm
in version 3. the "#movenextbtn,#movesubmitbtn" have other IDs.
Now it is "#ls-button-submit"
Check by using a webdeveloper tool.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- bruce78
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 77
- Thank you received: 4
6 years 1 month ago #164660
by bruce78
Thank you Joffm - the code below now hides the 'Next' button and auto-advances on dropdown questions but nothing happens on radio button array questions...
Looking at the developer tools in Google, I've tried changing
to
and
with no joy... do you know what else I need to change for the auto advancing to work on radio array type questions?
Replied by bruce78 on topic How to auto-advance to the next question in Version 3
Joffm wrote: in version 3. the "#movenextbtn,#movesubmitbtn" have other IDs.
Now it is "#ls-button-submit"
Thank you Joffm - the code below now hides the 'Next' button and auto-advances on dropdown questions but nothing happens on radio button array questions...
Looking at the developer tools in Google, I've tried changing
Code:
tr.radio-list
Code:
td.radio-item
Code:
.radio-item
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ $('tr.radio-list input.radio').bind('click', function () { var thisArray = $(this).closest('table'); if($('input.radio:checked', thisArray).length == $('tr.radio-list', thisArray).length) { $("#ls-button-submit").delay(1).click(); } }); $(".list-dropdown select").change(function(){ if($(this).val()!="" && $(this).val()!="-oth-"){ $("#ls-button-submit").delay(1).click(); } }); $('#ls-button-submit').hide(); }); </script>
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12888
- Thank you received: 3965
6 years 1 month ago #164661
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic How to auto-advance to the next question in Version 3
Hi, bruce,
yes, the radios are different, because it is not table-based anymore.
But - to be honest - I am not very familiar with JS. Therefore no solution from my side, sorry.
Joffm
yes, the radios are different, because it is not table-based anymore.
But - to be honest - I am not very familiar with JS. Therefore no solution from my side, sorry.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12888
- Thank you received: 3965
6 years 1 month ago - 6 years 1 month ago #164663
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic How to auto-advance to the next question in Version 3
Hi, bruce,
I found this in
www.limesurvey.org/forum/can-i-do-this-w...ter-selecting-answer
three days ago.
Autoproceed of radios.
Regards
Joffm
I found this in
www.limesurvey.org/forum/can-i-do-this-w...ter-selecting-answer
three days ago.
Autoproceed of radios.
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>
Regards
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 6 years 1 month ago by Joffm.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
6 years 1 month ago #164666
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 How to auto-advance to the next question in Version 3
Yes, there is no longer a "radio" class assigned to the inputs so you need to use the type selector:
Code:
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ $('tr.radio-list input[type="radio"]').bind('click', function () { var thisArray = $(this).closest('table'); if($('input[type="radio"]:checked', thisArray).length == $('tr.radio-list', thisArray).length) { $("#ls-button-submit").delay(1).click(); } }); $(".list-dropdown select").change(function(){ if($(this).val()!="" && $(this).val()!="-oth-"){ $("#ls-button-submit").delay(1).click(); } }); $('#ls-button-submit').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.
- bruce78
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 77
- Thank you received: 4
6 years 1 month ago #164699
by bruce78
Replied by bruce78 on topic How to auto-advance to the next question in Version 3
Great, thank you - that seems to have worked after a quick test! I'll see how I get on...
The topic has been locked.
- bruce78
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 77
- Thank you received: 4
6 years 1 month ago #164709
by bruce78
Replied by bruce78 on topic How to auto-advance to the next question in Version 3
If I want to do a find/replace type exercise in mysql to update the script to this new code, are there any pointers or tips for LimeSurvey? The scripts are all inserted into the question source with the corresponding <script> tags...
I know some people talk about serialisation as something to watch out for in WordPress but are there any issues to be aware of that might affect LimeSurvey at all?
I know some people talk about serialisation as something to watch out for in WordPress but are there any issues to be aware of that might affect LimeSurvey at all?
The topic has been locked.
- bruce78
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 77
- Thank you received: 4
6 years 1 month ago #165312
by bruce78
Replied by bruce78 on topic How to auto-advance to the next question in Version 3
ok, so having looked into this, the mysql statement below seems to work fine as a way of mass updating strings in questions or in other fields...
if you run into problems with charachters that need to be escaped and this includes a lot of punctuation, quotes, hashes and so on, mysql workbench is a quick way to check your syntax...
if you run into problems with charachters that need to be escaped and this includes a lot of punctuation, quotes, hashes and so on, mysql workbench is a quick way to check your syntax...
Code:
UPDATE `ls_db`.`ls_table` SET `ls_field` = replace(ls_field, 'unwanted_text', 'wanted_text');
The topic has been locked.