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
  • AdrianB's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 11 months ago - 7 years 11 months ago #136016 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:
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 &amp;&amp; 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
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 11 months ago #136046 by tpartner
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 &amp;&amp; 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
  • AdrianB's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 11 months ago #136217 by AdrianB
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.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose