Welcome to the LimeSurvey Community Forum

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

Restrict the answers to a Multiple Choice question with Exclusive Answer

  • davebostockgmail
  • davebostockgmail's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
3 years 1 week ago #213709 by davebostockgmail
I had a problem with a multiple choice question where the respondent HAD to choose their top 3 answers BUT the question had an exclusive option in the list. 

After trying unsuccessfully to do this with the question validation, I still cannot get that to work for me I should look into it more, I came up with the following script that may be helpful to others in this situation

On a mandatory Multiple Choice question I used this...

// Stop the next button submitting the answers
$('#ls-button-submit').bind('click', function () { 

//The answer code for the Exclusive Option
if ( !$("#answer172258X582X2244812").prop('checked')) {

      // The count of required answers
     if  ($("input:checkbox:checked").length !=3 ) {

                 // The message that comes up on trying to submit the question if the Exclusive option is not selected or the number of answers is not the required count.
                alert("Please select three messages.");
            return false; 
            }
      }
});


Hope this can help someone else

This works on Limesurvey 3.25
 
The following user(s) said Thank You: tpartner
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 1 week ago - 3 years 1 week ago #213721 by DenisChenu

After trying unsuccessfully to do this with the question validation, I still cannot get that to work for me I should look into it more, I came up with the following script that may be helpful to others in this situation


 
Without using included exclude, question code to Q00

(count(self.NAOK==1) and !is_empty(Q00_EXCLUDE.NAOK) )
OR
(count(self.NAOK==3) and is_empty(Q00_EXCLUDE.NAOK) )

no ?

[EDIT] and with exclude option
!is_empty(Q00_EXCLUDE.NAOK) or count(self.NAOK) == 3
(sample survey)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Last edit: 3 years 1 week ago by DenisChenu. Reason: [EDIT]
The following user(s) said Thank You: davebostockgmail
The topic has been locked.
  • davebostockgmail
  • davebostockgmail's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
3 years 6 days ago #213790 by davebostockgmail
Thanks Denis, I will experiment with the question validation some more as this seems simpler.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose