Welcome to the LimeSurvey Community Forum

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

how to add several 'other' options to multiple choice question?

  • douerliang
  • douerliang's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 11 months ago #134546 by douerliang
hello everyone,

Today I encountered a problem when designing a survey. The problem is I can add only one 'other' option in the multiple choice question.
But i want to add a few more.
Can someone help me?ths


i'm sorry for my english!
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 11 months ago - 7 years 11 months ago #134564 by tpartner
I think the only solution is to use a Multiple choice with comments type question and hide some of the text inputs with JavaScript or CSS.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 7 years 11 months ago by tpartner.
The following user(s) said Thank You: DenisChenu, douerliang
The topic has been locked.
  • douerliang
  • douerliang's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 11 months ago #134616 by douerliang

tpartner wrote: I think the only solution is to use a Multiple choice with comments type question and hide some of the text inputs with JavaScript or CSS.


Hey , tpartner
Thank you very much for your replay ! I think the solution you provide is great ! Thank you !
The topic has been locked.
More
7 years 3 months ago #146058 by BBCMResearch
Tony,

I'm having this same problem can you link to any javascript that's been posted about this? I haven't come across it yet.

Thanks!
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 3 months ago #146072 by DenisChenu

BBCMResearch wrote: Tony,

I'm having this same problem can you link to any javascript that's been posted about this? I haven't come across it yet.

Thanks!

Quick javascript solution :
Code:
<script>
$(function() {
  $("#answer{SGQ}SQ0001comment").hide();
});
</script>
If i don't make error in the id (use browser dev tool to know it, and remind the {SGQ} replace 12654X65X5656 part).

Denis

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.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 3 months ago #146117 by tpartner
I think it may be better to completely remove the inputs in case someone is tabbing through the survey.

Code:
<script type="text/javascript" charset="utf-8">  
 
  $(document).ready(function() {
 
    $('#question'+{QID}+' .comment-container:eq(0) *').remove(); // First input
    $('#question'+{QID}+' .comment-container:eq(1) *').remove(); // Second input
 
  });
</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: DenisChenu
The topic has been locked.
More
6 years 10 months ago #154795 by BBCMResearch
Tony,

Not sure what happened, but after a recent update, we noticed some of the script we had used on a survey stopped working, and for the life of me I cannot find what it was supposed to look like. It was some sort of combination of the above - hiding text inputs on a multiple choice with comments, and then one you gave here:
www.limesurvey.org/forum/can-i-do-this-w...mized-answers#146118

Essentially, I have a multiple choice with comments type question with 6 subquestions. Subquestion 6 needs to be permamently pinned to the bottom of the screen, and only subquestions 5 & 6 need to have comment boxes.

However, subquestions 1-5 need to be randomized on each load, and all 6 subquestions need to be exclusive options.

Please help.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 10 months ago #154810 by tpartner
Can you please attach a small test survey containing only that question and your script?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
6 years 10 months ago #154835 by BBCMResearch
Tony, please see attached.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 10 months ago #154840 by tpartner
I'm not sure how this ever worked. The problem is that you are removing the text inputs based on row position before moving the "fixed" rows to the end of the list. That means that text inputs could be removed from your "fixed" rows.

It would be safer to identify the rows to have the text inputs removed by their sub-question codes, remove them and then move the "fixed" rows.

Code:
<script type="text/javascript" charset="utf-8">
  $(document).ready(function() {
 
    // Identify this question
    var qID = {QID}; 
 
    // The sub-question codes to have no text input
    var sqCodes = [1, 2, 3, 4]; 
 
    // Loop through those sq codes and remove their text inputs
    $(sqCodes).each(function(i, code) {
      $('#question'+qID+' input[type="text"][id$="X7441'+code+'comment"]').remove();
    });
 
    // The number of answers to be fixed at the end of the list
    var fixedAnswers = 2;
 
    // Find the number of answers
    var ansCount = $('#question'+qID+' .answer-item').length;
 
    // Place the last n answers created at the end of the list
    var fixedIndex = fixedAnswers - 1;
    for (var i=0; i<fixedAnswers; i++) {
      var answer = $('input[id^="answer"][id$="X'+qID+(ansCount-fixedIndex)+'"]');
      var answerItem = $(answer).closest('.answer-item');
      var answersList = $(answer).closest('.answers-list');
      if($('#question'+qID).hasClass('multiple-opt')) {
        answerItem = $(answer).closest('.answer-item').parent();
        answersList = $(answer).closest('.subquestion-list');
      }
      if($('#question'+qID).hasClass('multiple-opt-comments')) {
        answersList = $(answer).closest('tbody');
      }
      $(answersList).append(answerItem);
      fixedIndex--;
    }    
  });
</script>



Sample survey attached:

File Attachment:

File Name: limesurvey...7561.lss
File Size:29 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
6 years 10 months ago #154841 by BBCMResearch
Thanks Tony,

I knew that was the problem but didn't know how to address it. I feel like we had it worked out previously, but when we logged in this week to check the survey, portions of html script had disappeared and the rest just showed up as regular question text. No idea why.

Also, for some reason, this code isn't working for me. The bottom two sq's remain fixed like they're supposed to while the others rotate around randomly, however all of them still have textboxes. This happens both when I paste the above code into my survey question, and also when I load the survey you attached.
Just ran your sample survey.

Attachments:
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 10 months ago #154842 by tpartner
Can you activate a test survey and link it here?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose