- Posts: 15
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
How to creates pop-ups messages before submit
- MSMSEVN
- Topic Author
- Offline
- New Member
Less
More
6 years 8 months ago #156136
by MSMSEVN
How to creates pop-ups messages before submit was created by MSMSEVN
A few of participants close the survey by close web page, not submitted. I want to make a pop-ups message to ask them:"U've undone this survey. Are you sure you want to quit?" How to do that?
Many thanks
Many thanks
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3690
6 years 8 months ago - 6 years 8 months ago #156153
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 creates pop-ups messages before submit
You can use the "beforeunload event, although the behaviour is not standardized across browsers.
Add something like this to the end of template.js:
Add something like this to the end of template.js:
Code:
$(document).ready(function(){ $(window).bind("beforeunload", function(event) { return "Your data will not be saved!"; }); $('#movenextbtn, #movesubmitbtn').on('click', function () { $(window).unbind("beforeunload"); }); });
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 6 years 8 months ago by tpartner.
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11746
- Thank you received: 2750
6 years 8 months ago #156155
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic How to creates pop-ups messages before submit
Shouldn't this go into the javascript file rather the template.css?
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3690
6 years 8 months ago #156156
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 creates pop-ups messages before submit
Oops, yes, of course.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- MSMSEVN
- Topic Author
- Offline
- New Member
Less
More
- Posts: 15
- Thank you received: 0
6 years 8 months ago #156194
by MSMSEVN
Replied by MSMSEVN on topic How to creates pop-ups messages before submit
Thank for your response. But I still have a problem with pop-ups message. My survey is non-anonymous survey,so when I add this code to template.js, It's only appear on the register page (attached file). From welcome page to last page, It doesn't work. What can I do next?
Thanks in advance!
Thanks in advance!
Attachments:
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3690
6 years 8 months ago #156202
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 creates pop-ups messages before submit
Try this:
Code:
$(document).ready(function(){ if($('#movenextbtn, #movesubmitbtn').length > 0) { $(window).bind("beforeunload", function(event) { return "Your data will not be saved!"; }); $('#movenextbtn, #movesubmitbtn').on('click', function () { $(window).unbind("beforeunload"); }); } });
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.