Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Interdependent Multiple Choice Questions Issue

  • yufabeen
  • yufabeen's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 8 months ago #218796 by yufabeen
I have an issue in my survey where the following can occur:



Basically, one could end up with a question, where nothing can be selected anymore because all options are grayed out.

A minimal example survey to import, where it can be reproduced is here:

 

File Attachment:

File Name: mini surve...mple.txt
File Size:23 KB


The script which does the graying out might not import correctly. It can be replaced manually by copy-pasting using the following:
Code:
Q2: (Single Choice) <script type="text/javascript" charset="utf-8">
  $(document).ready(function() {
 
                // Maximum answers
                var maxAnswers = 1;
 
                // Identify this question
 
                var thisQuestion = $('#question{QID}');
 
                function checkMax() {
                        $('input[type="checkbox"]', thisQuestion).prop('disabled', false);
                        if($('input[type="checkbox"]:checked', thisQuestion).length >= maxAnswers) {
                                $('input[type="checkbox"]', thisQuestion).not(':checked').prop('disabled', true);
                        }
                }
    
                // Initial checkbox states
                checkMax();
      
                // Listener on the checkboxes
                $('input[type="checkbox"]', thisQuestion).change(function(e) {
                        checkMax();
                });
 
                // Remove any "disabled" properties before submitting
                $('#ls-button-submit').bind('click', function () {
                        $('input[type="checkbox"]', thisQuestion).prop('disabled', false);
                });
 
    });
</script>

The issue arises when a respondent fills out Q1 and Q2 linearly and normally, but then goes back – for whatever reason (e.g. having noticed a misclick or change of opinion) – to deselect in Q1 what also happens to be the choice of Q2. Then the other ones that were selected in Q1 just appear gray and non-clickable in Q2. In that scenario, how is it possible to make them reset automatically to be clickable again (without the respondent having to manually re-select it in Q1 and then un-select it in Q2 to get rid of the gray, which could be frustrating to figure out and might cause the respondent to cancel filling out the survey entirely)?

Any help on this would be greatly appreciated!
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose