- Posts: 17
- Thank you received: 1
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Detect unanswered radio list question if "No answer" is hidden
- AdrianB
- Topic Author
- Offline
- New Member
Less
More
7 years 11 months ago - 7 years 11 months ago #136016
by AdrianB
Detect unanswered radio list question if "No answer" is hidden was created by AdrianB
Hi all,
As part of a survey to support medical research, we are trying to issue a pop-up reminder to participants if they have not answered one or more radio list questions in a question group. The questions do not have a default selection, and by the survey design, we choose to hide the "No answer" option in the radio lists.
tpartner's code at www.limesurvey.org/forum/can-i-do-this-w...efault-in-radio-list works well, but only for surveys that display the "No answer" option.
How would you modify the JavaScript, or write different JavaScript, to issue the pop-up reminder if any one or more radio list questions are unanswered and we have disabled the "No answer" option in the survey's general settings?
tpartner's code is quoted below:
As part of a survey to support medical research, we are trying to issue a pop-up reminder to participants if they have not answered one or more radio list questions in a question group. The questions do not have a default selection, and by the survey design, we choose to hide the "No answer" option in the radio lists.
tpartner's code at www.limesurvey.org/forum/can-i-do-this-w...efault-in-radio-list works well, but only for surveys that display the "No answer" option.
How would you modify the JavaScript, or write different JavaScript, to issue the pop-up reminder if any one or more radio list questions are unanswered and we have disabled the "No answer" option in the survey's general settings?
tpartner's code is quoted below:
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { var confirmShown = 0; // Interrupt the submit process $('#movenextbtn, #movesubmitbtn').bind('click', function () { if($('input.radio[value=""]:checked').length > 0 && confirmShown == 0) { confirmShown = 1; var moveOn = confirm("Some questions remain unanswered. \nDo you want to continue?"); if (moveOn == false) { return false; } } }); }); </script>
Last edit: 7 years 11 months ago by AdrianB.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10104
- Thank you received: 3593
7 years 11 months ago #136046
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 Detect unanswered radio list question if "No answer" is hidden
Try this:
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { var confirmShown = 0; // Interrupt the submit process $('#movenextbtn, #movesubmitbtn').bind('click', function () { if($('input.radio:checked').length != $('.list-radio:visible').length && confirmShown == 0) { confirmShown = 1; var moveOn = confirm("Some questions remain unanswered. \nDo you want to continue?"); if (moveOn == false) { return false; } } }); }); </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: AdrianB
The topic has been locked.
- AdrianB
- Topic Author
- Offline
- New Member
Less
More
- Posts: 17
- Thank you received: 1
7 years 11 months ago #136217
by AdrianB
Replied by AdrianB on topic Detect unanswered radio list question if "No answer" is hidden
tpartner, thank you very much -- your code works perfectly!
A nice, concise solution too -- I was thinking of the problem in terms of iterating through the visible radio lists, but yours achieves the same thing with much less code.
Thanks again,
Adrian.
A nice, concise solution too -- I was thinking of the problem in terms of iterating through the visible radio lists, but yours achieves the same thing with much less code.
Thanks again,
Adrian.
The topic has been locked.