- Posts: 115
- Thank you received: 4
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
setTimeout on Submit
- dweisser
- Topic Author
- Offline
- Premium Member
Less
More
8 years 1 month ago #132733
by dweisser
setTimeout on Submit was created by dweisser
Hi all,
I'm having trouble delaying the survey submit for 5 seconds. After 5 seconds the respondent should be redirected based the value of a set of answers. All works well, except for the delay. It seems like this should be straight forward, but I can't seem to get it to work.
// Interrupt the Next/Submit click
$('#movenextbtn, #movesubmitbtn').bind('click', function () {
var SumRating =document.getElementById('java331225X350X2914').value;
if(SumRating>=20){
$('div#redirect_popup').css({'display':''});
setTimeout(function() { window.location.href = " plus.google.com/+Rep1stco/about "; }, 5000 );
//window.top.location.href = " plus.google.com/company/about ";
} else {
window.top.location.href = " company.com ";
}
});
Any thoughts are always appreciated. Thanks!
I'm having trouble delaying the survey submit for 5 seconds. After 5 seconds the respondent should be redirected based the value of a set of answers. All works well, except for the delay. It seems like this should be straight forward, but I can't seem to get it to work.
// Interrupt the Next/Submit click
$('#movenextbtn, #movesubmitbtn').bind('click', function () {
var SumRating =document.getElementById('java331225X350X2914').value;
if(SumRating>=20){
$('div#redirect_popup').css({'display':''});
setTimeout(function() { window.location.href = " plus.google.com/+Rep1stco/about "; }, 5000 );
//window.top.location.href = " plus.google.com/company/about ";
} else {
window.top.location.href = " company.com ";
}
});
Any thoughts are always appreciated. Thanks!
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10098
- Thank you received: 3589
8 years 1 month ago #132750
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 setTimeout on Submit
It seems to me that this should be done in the End Message.
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
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 115
- Thank you received: 4
8 years 1 month ago #132752
by dweisser
Replied by dweisser on topic setTimeout on Submit
You're probably right. Can I show different end messages based on the response to that Equation question? I was hoping that I can show a message on the same page of the survey based on that response so that the respondent only sees one page before they are redirected.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10098
- Thank you received: 3589
8 years 1 month ago #132754
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 setTimeout on Submit
You can use Expression Manager to tailor the End Message depending on survey responses. I'm just not sure I would mess with the Next/Submit button that way - it may prevent the survey from submitting.
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
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 115
- Thank you received: 4
8 years 1 month ago #132755
by dweisser
Replied by dweisser on topic setTimeout on Submit
I'll have a look at it/ The preference is single page only.
The survey does submit, and the redirection works...it just doesn't delay. I found some other script that Denis wrote that does something similar, but I'm not sure if I can apply it for this situation.
The survey does submit, and the redirection works...it just doesn't delay. I found some other script that Denis wrote that does something similar, but I'm not sure if I can apply it for this situation.
Code:
$(".submit").hide(); $("#imageload").load(function() { window.setTimeout(function() { $('#movenextbtn').click(); }, 5000) });
The topic has been locked.
- dweisser
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 115
- Thank you received: 4
8 years 1 month ago #132763
by dweisser
Replied by dweisser on topic setTimeout on Submit
Tpartner,
This works, and posts to the database - but I'm with you. I still don't think it's a great idea. Just posting for completeness' sake. Have a good one!
This is in the text elements of the survey:
This works, and posts to the database - but I'm with you. I still don't think it's a great idea. Just posting for completeness' sake. Have a good one!
Code:
$(".submit").hide(); //hide the native submit button $('#question2897').after('<button id="newSubmit"class="submit" type="button">Submit</button>'); //add in a custom button $('#question2897').before('<div id="redirect_popup">Thank you for the positive feedback.<br>Please take a moment to write us a short online review. It helps our search engine rankings - and it is good karma!</div>'); $("#newSubmit").click(function() { $('div#redirect_popup').css({'display':''}); window.setTimeout(function() { $("#movesubmitbtn").click(); }, 5000) });
This is in the text elements of the survey:
Code:
{if(A2>=20,'https://plus.google.com/+CompanyName/about', 'https://www.CompanyName.com/')} so based on the score of question names A2, the redirect happens without additional JavaScript.
The topic has been locked.