- Posts: 31
- Thank you received: 1
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
- Topic Author
- Offline
- Junior Member
Less
More
8 years 1 week ago #134546
by douerliang
how to add several 'other' options to multiple choice question? was created 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!
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3593
8 years 1 week ago - 8 years 1 week ago #134564
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic how to add several 'other' options to multiple choice question?
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: 8 years 1 week ago by tpartner.
The following user(s) said Thank You: DenisChenu, douerliang
The topic has been locked.
- douerliang
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 31
- Thank you received: 1
8 years 1 week ago #134616
by douerliang
Hey , tpartner
Thank you very much for your replay ! I think the solution you provide is great ! Thank you !
Replied by douerliang on topic how to add several 'other' options to multiple choice question?
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.
- BBCMResearch
- Offline
- Senior Member
Less
More
- Posts: 73
- Thank you received: 1
7 years 4 months ago #146058
by BBCMResearch
Replied by BBCMResearch on topic how to add several 'other' options to multiple choice question?
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!
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13643
- Thank you received: 2491
7 years 4 months ago #146072
by DenisChenu
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.
Replied by DenisChenu on topic how to add several 'other' options to multiple choice question?
Quick javascript solution :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!
Code:
<script> $(function() { $("#answer{SGQ}SQ0001comment").hide(); }); </script>
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3593
7 years 4 months ago #146117
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic how to add several 'other' options to multiple choice question?
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.
- BBCMResearch
- Offline
- Senior Member
Less
More
- Posts: 73
- Thank you received: 1
6 years 11 months ago #154795
by BBCMResearch
Replied by BBCMResearch on topic how to add several 'other' options to multiple choice question?
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.
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3593
6 years 11 months ago #154810
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic how to add several 'other' options to multiple choice question?
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.
- BBCMResearch
- Offline
- Senior Member
Less
More
- Posts: 73
- Thank you received: 1
6 years 11 months ago #154835
by BBCMResearch
Replied by BBCMResearch on topic how to add several 'other' options to multiple choice question?
Tony, please see attached.
Attachments:
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3593
6 years 11 months ago #154840
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic how to add several 'other' options to multiple choice question?
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.
Sample survey attached:
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:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The topic has been locked.
- BBCMResearch
- Offline
- Senior Member
Less
More
- Posts: 73
- Thank you received: 1
6 years 11 months ago #154841
by BBCMResearch
Replied by BBCMResearch on topic how to add several 'other' options to multiple choice question?
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.
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3593
6 years 11 months ago #154842
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic how to add several 'other' options to multiple choice question?
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.