- Posts: 2
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Array checkbox with mandatory answer per column
- ezraboni
- Topic Author
- Offline
- New Member
Less
More
2 weeks 5 minutes ago #262415
by ezraboni
Array checkbox with mandatory answer per column was created by ezraboni
Please help us help you and fill where relevant:
Your LimeSurvey version: [see right hand bottom of your LimeSurvey admin screen]
Own server or LimeSurvey hosting:
Survey theme/template:
==================
(Write here your question/remark)Hi,
I'm new to Limesurvey and would like to know if it is possible to either (1) Combine 2 multiple choice questions in one table, or (2) Make array numbers (checkbox) mandatory per columns instead of per row? Whichever is easier. The result should look like this:
Which attributes do you associate with the following categories?
[Multiple choice per column]
Category 1 Category 2
Attribute 1 Checkbox Checkbox
Attribute 2 Checkbox Checkbox
Attribute 3 Checkbox Checkbox
Attribute 4 Checkbox Checkbox
Attribute 5 Checkbox Checkbox
Attribute 6 Checkbox Checkbox
Attribute 7 Checkbox Checkbox
Attribute 8 Checkbox Checkbox
Attribute 9 Checkbox Checkbox
Attribute 10 (Others, specify: ______) Checkbox Checkbox
Thank you so much in advance!
Regards,
Ezra
Your LimeSurvey version: [see right hand bottom of your LimeSurvey admin screen]
Own server or LimeSurvey hosting:
Survey theme/template:
==================
(Write here your question/remark)Hi,
I'm new to Limesurvey and would like to know if it is possible to either (1) Combine 2 multiple choice questions in one table, or (2) Make array numbers (checkbox) mandatory per columns instead of per row? Whichever is easier. The result should look like this:
Which attributes do you associate with the following categories?
[Multiple choice per column]
Category 1 Category 2
Attribute 1 Checkbox Checkbox
Attribute 2 Checkbox Checkbox
Attribute 3 Checkbox Checkbox
Attribute 4 Checkbox Checkbox
Attribute 5 Checkbox Checkbox
Attribute 6 Checkbox Checkbox
Attribute 7 Checkbox Checkbox
Attribute 8 Checkbox Checkbox
Attribute 9 Checkbox Checkbox
Attribute 10 (Others, specify: ______) Checkbox Checkbox
Thank you so much in advance!
Regards,
Ezra
Please Log in to join the conversation.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13031
- Thank you received: 4007
1 week 6 days ago - 1 week 6 days ago #262474
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Array checkbox with mandatory answer per column
Hi,
at first you have to consider:
These are two independent questions.
1a. Which attributes do you associate with category 1?
1b. Which attributes do you associate with category 2?
Both "multiple". This is straightforward, easy and built-in.
Additionally you may display these two questions side by side, like this
As here you only display two multiple questions your requirement is still fulfilled.
Unfortunately you did not answer the questions at the beginning (why not?)
Therefore we can't know if you are allowed to use javascript.
But here it is.
Put it in one of the questions (and you have to enter into css classes: "flex-layout")
And of course you can use an array(numbers) with checkbox layout.
Here you have to use your own question validation equation to make sure that there is at least one checkbox per column selected.
Furthermore you have to insert the "Other"-option.
Add a question of type "short text" after your array
Put this script into the array question
Like this
Joffm
at first you have to consider:
These are two independent questions.
1a. Which attributes do you associate with category 1?
1b. Which attributes do you associate with category 2?
Both "multiple". This is straightforward, easy and built-in.
Additionally you may display these two questions side by side, like this
As here you only display two multiple questions your requirement is still fulfilled.
Unfortunately you did not answer the questions at the beginning (why not?)
Therefore we can't know if you are allowed to use javascript.
But here it is.
Put it in one of the questions (and you have to enter into css classes: "flex-layout")
Code:
<script type="text/javascript" data-author="Tony Partner"> $(document).ready(function() { // The number of questions to wrap in the flex container var numberQuestions = 2; // Identify the questions var thisQuestion = $('#question{QID}'); var rowQuestions = thisQuestion.add(thisQuestion.nextAll('.question-container:lt('+(numberQuestions-1)+')')); // Wrap the questions in a <div> element rowQuestions.wrapAll('<div class="question-flex-container" />'); }); </script>
Code:
<style type="text/css">@media only screen and (min-width: 576px) { .question-flex-container { display: flex; justify-content: space-evenly; } .flex-layout.question-container { width:100%; } </style>
And of course you can use an array(numbers) with checkbox layout.
Here you have to use your own question validation equation to make sure that there is at least one checkbox per column selected.
Furthermore you have to insert the "Other"-option.
Add a question of type "short text" after your array
Put this script into the array question
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify the questions var thisQuestion = $('#question'+{QID}+''); var nextQuestion1 = $(thisQuestion).nextAll('.text-short:eq(0)'); var nextQuestions = $(nextQuestion1); var nextLength = nextQuestions.length; var sqLength = ('tr.answers-list', thisQuestion).length; // Hide the short-text questions $(nextQuestions).hide(); // Move the hidden text inputs into the array for (i = 0; i < nextLength; i++) { var workingIndex = (sqLength - 1) - (nextLength - i); var nextQ = nextQuestions[i]; $('th.answertext:eq('+workingIndex+')', thisQuestion).append($('input[type="text"]', nextQ)).closest('tr').addClass('otherRow'); } // Some styling... $('input[type="text"]', thisQuestion).css({ 'width': '100%' }); }); </script>[/i]
Like this
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 1 week 6 days ago by Joffm.
The following user(s) said Thank You: DenisChenu
Please Log in to join the conversation.
- ezraboni
- Topic Author
- Offline
- New Member
Less
More
- Posts: 2
- Thank you received: 0
1 week 6 days ago - 1 week 6 days ago #262508
by ezraboni
Replied by ezraboni on topic Array checkbox with mandatory answer per column
Hi Joffm,
Thank you so much for the quick response! I used your solution for array question and added a question validation per your instruction. It's working fine on my end.
Again, thank you so much for the help!
Regards,
Ezra
Thank you so much for the quick response! I used your solution for array question and added a question validation per your instruction. It's working fine on my end.
Again, thank you so much for the help!
Regards,
Ezra
Last edit: 1 week 6 days ago by ezraboni.
Please Log in to join the conversation.