Welcome to the LimeSurvey Community Forum

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

Not a Question but a share - Multiple Other Specifies on a Multiple Choice Q

  • davebostockgmail
  • davebostockgmail's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
2 years 6 days ago #227295 by davebostockgmail
Please help us help you and fill where relevant:
Your LimeSurvey version: 5.X
Own server or LimeSurvey hosting: Own
Survey theme/template: 
==================

One of the things I have been asked to do more and more often is to have a multiple choice question which has more than one other specify answer in it ... so I thought I would share what I have done to meet this.

First of all I used a multiple choice with comments question to enable the input boxes to be shown for each answer.

Then I removed the input boxes that were not for the other specify options with a simple script (One line per box to be removed)... 

$('#answer829445X923X417661comment').css("display","none");

This meant that I had the desired look of the question 

Now all that was left was to ensure that if they selected any of the other specify answers the survey would not continue without the corresponding text entry in that input box (without this the respondent could check the other box and move on without answering the other part)

This was done with the following script (In this instance there were 4 other specify options needed)  .....

<script>
    $(document).on('ready pjax:scriptcomplete',function(){
         $('#ls-button-submit').bind('click', function () {
            if($("#answer829445X923X417668comment").val().length < 1 && $('#answer829445X923X417668').is(':checked')) {
                       var moveOn = alert("You need to enter the job title in the other specify box before you can continue");
                return false;
            }
          if($("#answer829445X923X417669comment").val().length < 1 && $('#answer829445X923X417669').is(':checked') ) {
                       var moveOn = alert("You need to enter the job title in the other specify box before you can continue");
                return false;
            }
          if($("#answer829445X923X4176610comment").val().length < 1 && $('#answer829445X923X4176610').is(':checked') ) {
                           var moveOn = alert("You need to enter the job title in the other specify box before you can continue");
                return false;
            }
          if($("#answer829445X923X4176611comment").val().length < 1 && $('#answer829445X923X4176611').is(':checked') ) {
                     var moveOn = alert("You need to enter the job title in the other specify box before you can continue");
                return false;
            }
        });
     });
</script>

I hope this helps if someone has a similar issue ....

 

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 6 days ago #227299 by tpartner
It is safer to remove the inputs instead of hiding them. This will prevent people tabbing into them.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

  • davebostockgmail
  • davebostockgmail's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
2 years 5 days ago #227303 by davebostockgmail
Good call I have made the changes to do just that .... $('#answer829445X923X417661comment').css("display","none"); now reads $('#answer829445X923X417661comment').remove();

Thanks for the advice.
 

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose