- Posts: 115
- Thank you received: 4
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Automatically proceed to next question (without clicking "next")
- dweisser
- Offline
- Premium Member
Less
More
10 years 3 weeks ago #107123
by dweisser
Replied by dweisser on topic Automatically proceed to next question (without clicking "next")
For the record,
I'm not auto-submitting surveys. In the end, no body wants that. However, I was working with the code and trying to figure out why this wont work:
There seems to be something wrong with this:
, but I can't figure out what it is. If I simple put this:
in the timer block without a condition - it auto submits. What gives?
Any thoughts would be appreciated.
David
I'm not auto-submitting surveys. In the end, no body wants that. However, I was working with the code and trying to figure out why this wont work:
Code:
// Page timeout action function pageTimeout() { //window.location = redirectURL; // Find the group index var groupIndex = $('div[id^="group-"]').attr('id').split('group-')[1]; if(groupIndex[0] >= 0) { $('#movesubmitbtn').click(); } else { window.location = redirectURL; } }
There seems to be something wrong with this:
Code:
$('#movesubmitbtn').click();
Code:
$('#movesubmitbtn').click();
Any thoughts would be appreciated.
David
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10108
- Thank you received: 3593
10 years 3 weeks ago #107124
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 Automatically proceed to next question (without clicking "next")
Hard to say without seeing all of the code but it seems to me that groupIndex is an array item, not an array.
So, this:
Should be this:
So, this:
Code:
if(groupIndex[0] >= 0) {
Should be this:
Code:
if(groupIndex >= 0) {
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- dweisser
- Offline
- Premium Member
Less
More
- Posts: 115
- Thank you received: 4
10 years 2 weeks ago - 10 years 2 weeks ago #107144
by dweisser
Replied by dweisser on topic Automatically proceed to next question (without clicking "next")
I had tried that, T. And everything else. HEre is the whole code block.
It just won't work inside the condition - and its making me crazy!
It just won't work inside the condition - and its making me crazy!
Code:
$(document).ready(function(){ var txtAlertMessage = 'Anyone there? Do you want to continue?'; var txtCloseButton = 'Continue'; var redirectURL = location.pathname.split('index.php')[0]; var timeToAlert = 2; // In seconds var timeToRedirect = 2; // In seconds // Page timeout action function pageTimeout() { // Find the group index - var groupIndex = $('div[id^="group-"]').attr('id').split('group-')[1]; if(groupIndex >= 0) { $('#movesubmitbtn').click(); } else { window.location = redirectURL; } } // Alert Timer var alertTimer; function startAlertTimer() { alertTimer = setTimeout(function() { $('.custom-dialog-1').dialog('open'); },timeToAlert*1000); } function stopAlertTimer() { clearTimeout(alertTimer); } function restartAlertTimer() { clearTimeout(alertTimer); startAlertTimer(); } startAlertTimer(); // Redirect Timer var redirectTimer; function startRedirectTimer() { redirectTimer = setTimeout(function() { pageTimeout(); },timeToRedirect*1000); } function stopRedirectTimer() { clearTimeout(redirectTimer); } function restartRedirectTimer() { clearTimeout(redirectTimer); startRedirectTimer(); } // Insert the alert dialog var timeoutDialog = '<div class="custom-dialog-1"> <div class="text">'+txtAlertMessage+'</div> <div class="buttons"> <button class="close" type="button" value="close">'+txtCloseButton+'</button> </div> </div>'; $(timeoutDialog).dialog({ autoOpen: false, open: function( event, ui ) { startRedirectTimer(); //IE 10 z-index hack $('.ui-widget-overlay').css('z-index', Number($('.ui-widget-overlay').css('z-index')) - 2); }, close: function( event, ui ) { stopRedirectTimer(); restartAlertTimer(); }, width: 400, modal: true, resizable: false, draggable: true, closeOnEscape: true, dialogClass: 'timeout-dialog' }); $('.timeout-dialog button').click(function() { $('.custom-dialog-1').dialog('close'); }); // Listener for activity $('#limesurvey').on('click keyup paste change' ,function(event){ restartAlertTimer(); }); });
Last edit: 10 years 2 weeks ago by dweisser.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10108
- Thank you received: 3593
10 years 2 weeks ago - 10 years 2 weeks ago #107145
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 Automatically proceed to next question (without clicking "next")
You have some syntax problems where inserting the timeoutDialog - it all needs to be on one line or escaped properly - see below.
Having said that, I just don't get what you are trying to do with the IF statement.
- You say if groupIndex is greater than or equal to 0, click Submit, otherwise redirect the page.
- Well, groupIndex will always be greater than or equal to 0 so the redirect will never happen.
- The #movesubmitbtn element only exists on the last page of the survey, so, unless you are there, nothing will ever happen.
Having said that, I just don't get what you are trying to do with the IF statement.
- You say if groupIndex is greater than or equal to 0, click Submit, otherwise redirect the page.
- Well, groupIndex will always be greater than or equal to 0 so the redirect will never happen.
- The #movesubmitbtn element only exists on the last page of the survey, so, unless you are there, nothing will ever happen.
Code:
$(document).ready(function(){ var txtAlertMessage = 'Anyone there? Do you want to continue?'; var txtCloseButton = 'Continue'; var redirectURL = location.pathname.split('index.php')[0]; var timeToAlert = 2; // In seconds var timeToRedirect = 2; // In seconds // Page timeout action function pageTimeout() { // Find the group index - var groupIndex = $('div[id^="group-"]').attr('id').split('group-')[1]; if(groupIndex >= 0) { $('#movesubmitbtn').click(); } else { window.location = redirectURL; } } // Alert Timer var alertTimer; function startAlertTimer() { alertTimer = setTimeout(function() { $('.custom-dialog-1').dialog('open'); },timeToAlert*1000); } function stopAlertTimer() { clearTimeout(alertTimer); } function restartAlertTimer() { clearTimeout(alertTimer); startAlertTimer(); } startAlertTimer(); // Redirect Timer var redirectTimer; function startRedirectTimer() { redirectTimer = setTimeout(function() { pageTimeout(); },timeToRedirect*1000); } function stopRedirectTimer() { clearTimeout(redirectTimer); } function restartRedirectTimer() { clearTimeout(redirectTimer); startRedirectTimer(); } // Insert the alert dialog var timeoutDialog = '<div class="custom-dialog-1">\ <div class="text">'+txtAlertMessage+'</div>\ <div class="buttons">\ <button class="close" type="button" value="close">'+txtCloseButton+'</button>\ </div>\ </div>'; $(timeoutDialog).dialog({ autoOpen: false, open: function( event, ui ) { startRedirectTimer(); //IE 10 z-index hack $('.ui-widget-overlay').css('z-index', Number($('.ui-widget-overlay').css('z-index')) - 2); }, close: function( event, ui ) { stopRedirectTimer(); restartAlertTimer(); }, width: 400, modal: true, resizable: false, draggable: true, closeOnEscape: true, dialogClass: 'timeout-dialog' }); $('.timeout-dialog button').click(function() { $('.custom-dialog-1').dialog('close'); }); // Listener for activity $('#limesurvey').on('click keyup paste change' ,function(event){ restartAlertTimer(); }); });
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 10 years 2 weeks ago by tpartner.
The topic has been locked.
- dweisser
- Offline
- Premium Member
Less
More
- Posts: 115
- Thank you received: 4
10 years 2 weeks ago #107152
by dweisser
Replied by dweisser on topic Automatically proceed to next question (without clicking "next")
Ahh, thank you. It makes sense now.
The topic has been locked.
- SurveyDennis
- Offline
- Senior Member
Less
More
- Posts: 72
- Thank you received: 10
9 years 5 months ago - 9 years 5 months ago #114492
by SurveyDennis
Be SurveyFriendly too! Fight against boring surveys! www.SurveyFriendly.com
Replied by SurveyDennis on topic Automatically proceed to next question (without clicking "next")
Hi,
Just curious, I am using this example with a normal list radio.
I have the question set to mandatory.
The code is working however I don't proceed to the next question properly.
A message popups -
Please use the LimeSurvey navigation buttons or index.
It appears you attempted to use the browser back button to re-submit a page.
(although I clicked the answer).
So in that case it looks like it is not saving the answer.
Any ideas?
Thanks, Dennis
Just curious, I am using this example with a normal list radio.
I have the question set to mandatory.
The code is working however I don't proceed to the next question properly.
A message popups -
Please use the LimeSurvey navigation buttons or index.
It appears you attempted to use the browser back button to re-submit a page.
(although I clicked the answer).
So in that case it looks like it is not saving the answer.
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ $( '#question{QID} input.radio' ).click(function() { document.limesurvey.submit(); }); }); </script>
Any ideas?
Thanks, Dennis
Be SurveyFriendly too! Fight against boring surveys! www.SurveyFriendly.com
Last edit: 9 years 5 months ago by SurveyDennis.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10108
- Thank you received: 3593
9 years 5 months ago #114496
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 Automatically proceed to next question (without clicking "next")
LimeSurvey version?
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- SurveyDennis
- Offline
- Senior Member
Less
More
- Posts: 72
- Thank you received: 10
9 years 5 months ago #114497
by SurveyDennis
Be SurveyFriendly too! Fight against boring surveys! www.SurveyFriendly.com
Replied by SurveyDennis on topic Automatically proceed to next question (without clicking "next")
Version 2.05
Be SurveyFriendly too! Fight against boring surveys! www.SurveyFriendly.com
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10108
- Thank you received: 3593
9 years 5 months ago #114498
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 Automatically proceed to next question (without clicking "next")
Try this:
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ $('#question{QID} input.radio').click(function() { checkconditions($(this).attr('value'), $(this).attr('name'), $(this).attr('type')) $('#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: SurveyDennis
The topic has been locked.
- SurveyDennis
- Offline
- Senior Member
Less
More
- Posts: 72
- Thank you received: 10
9 years 5 months ago #114499
by SurveyDennis
Be SurveyFriendly too! Fight against boring surveys! www.SurveyFriendly.com
Replied by SurveyDennis on topic Automatically proceed to next question (without clicking "next")
Many thanks, that did the trick!!
Much appreciated
Much appreciated
Be SurveyFriendly too! Fight against boring surveys! www.SurveyFriendly.com
The topic has been locked.
- MrHappyAndCo
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
7 years 10 months ago #137511
by MrHappyAndCo
Replied by MrHappyAndCo on topic Automatically proceed to next question (without clicking "next")
Hey there, I've been using the following code for quite some time now to automatically proceed to the next question:
Unfortunately, now that I upgraded LimeSurvey (Version 2.50+ Build 160606) I get the following message when choosing an answer option:
Any idea why this happens?
Thanks for the help!
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ $('#question{QID} input.radio').click(function() { checkconditions($(this).attr('value'), $(this).attr('name'), $(this).attr('type')) $('#movenextbtn, #movesubmitbtn').trigger('click'); }); }); </script>
Unfortunately, now that I upgraded LimeSurvey (Version 2.50+ Build 160606) I get the following message when choosing an answer option:
One or more mandatory questions have not been answered . Please answer this first to proceed !
Any idea why this happens?
Thanks for the help!
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10108
- Thank you received: 3593
7 years 10 months ago #137525
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 Automatically proceed to next question (without clicking "next")
It works fine for me using the default template and list-radio questions. What template and question types 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.