- Posts: 57
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Insert a row as answer options in choice task table for Multiple Choice question
- xueting
- Topic Author
- Offline
- Senior Member
Less
More
2 years 11 months ago #216522
by xueting
Replied by xueting on topic Insert a row as answer options in choice task table for Multiple Choice question
Thank you Joffm for your patience!
Now ratios finally have been moved into the table. But a new problem appears, that is nothing happened after adding the three lines of CSS for checkbox layout. And I carefully checked them, there shouldn't be the spelling mistakes (showing in the following picture).
I also attached the lss. file in case it will be needed.
I was wondering what seems to be the problem?
Thanks a lot for your help, Xueting
Now ratios finally have been moved into the table. But a new problem appears, that is nothing happened after adding the three lines of CSS for checkbox layout. And I carefully checked them, there shouldn't be the spelling mistakes (showing in the following picture).
I also attached the lss. file in case it will be needed.
I was wondering what seems to be the problem?
Thanks a lot for your help, Xueting
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12930
- Thank you received: 3978
2 years 11 months ago #216526
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Insert a row as answer options in choice task table for Multiple Choice question
Sorry, but now you are absolutely confused.
Your initial question was about a multiple choices
And you still use a "normal" array with the javascript workaround to insert the radios into the question text.
Here this css is absolutely useless. And as you see, not necessary.
And it is "single answer"
But your question was about a checkbox solution.(multiple possible answers).
And here the suitable question type is "array(numbers)".
Therefore I showed how you use an array(numbers) with checkbox layout and put it directly under your table in the question text (only with these three lines of css).
And you should remove the third row of your table. This is replaced by the question
And really urgent: Revise your HTML code.
You see the alignment of the "Option" row?
And look at this cell definition (how many times do you want to set the "font-size" or the "color")
<td bgcolor="#308737" style="text-align: center;" width="10%"><span style="font-size:11pt"><span style="font-family:Calibri,sans-serif"><span style="color:#ffffff;font-size:20px;"><span style="color:#ffffff;font-size:20px;"><strong>Option 6</strong></span> </span></span></span></td>
Your initial question was about a multiple choices
The thing is the question type in the examples is Array, however the question type in my case is Multiple Choice.
And you still use a "normal" array with the javascript workaround to insert the radios into the question text.
Here this css is absolutely useless. And as you see, not necessary.
And it is "single answer"
But your question was about a checkbox solution.(multiple possible answers).
And here the suitable question type is "array(numbers)".
Therefore I showed how you use an array(numbers) with checkbox layout and put it directly under your table in the question text (only with these three lines of css).
And you should remove the third row of your table. This is replaced by the question
And really urgent: Revise your HTML code.
You see the alignment of the "Option" row?
And look at this cell definition (how many times do you want to set the "font-size" or the "color")
<td bgcolor="#308737" style="text-align: center;" width="10%"><span style="font-size:11pt"><span style="font-family:Calibri,sans-serif"><span style="color:#ffffff;font-size:20px;"><span style="color:#ffffff;font-size:20px;"><strong>Option 6</strong></span> </span></span></span></td>
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- xueting
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 57
- Thank you received: 0
2 years 11 months ago #216530
by xueting
Replied by xueting on topic Insert a row as answer options in choice task table for Multiple Choice question
Oh I finally understand! Yes I was totally confused, thank you so much for pointing out all my problems. Now it works well, except a small question, that is how to move the asterisk mark * of mandatory from left side to top so as to make the alignment? Now it is in the left side of the table. I went to the setting-presentation, but failed to find a solution.
Thanks a lot! Xueting
Thanks a lot! Xueting
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12930
- Thank you received: 3978
2 years 11 months ago - 2 years 11 months ago #216537
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Insert a row as answer options in choice task table for Multiple Choice question
A you see in my screenshot, you have to add an empty line before your table in surce code
<p> </p>
Now you can proceed to insert a javascript snippet to make the last column exclusive
I do not have it on this machine, so I will sed it later.
Greetings to Eindhoven
Joffm
<p> </p>
Now you can proceed to insert a javascript snippet to make the last column exclusive
I do not have it on this machine, so I will sed it later.
Greetings to Eindhoven
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 2 years 11 months ago by Joffm.
The topic has been locked.
- xueting
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 57
- Thank you received: 0
2 years 11 months ago #216552
by xueting
Replied by xueting on topic Insert a row as answer options in choice task table for Multiple Choice question
Thank you Joffm! It really helps, and also thanks for reminding me of the exclusive issue of the last column, which is also a non-negligible issue.
I'm looking forward to your javascript snippet.
Thanks for your greetings
I'm looking forward to your javascript snippet.
Thanks for your greetings
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12930
- Thank you received: 3978
2 years 11 months ago #216560
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Insert a row as answer options in choice task table for Multiple Choice question
Add this to the question text (source code mode)
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Call the exclude function using question ID excludeOpt({QID}); }); // A function to make the last option in each array row exclusive function excludeOpt (qID) { var thisQuestion = $('#question'+qID) // Add some classes to the checkbox cells $('td.checkbox-item', thisQuestion).addClass('normal-item'); $('tr.subquestion-list', thisQuestion).each(function(i) { $('.normal-item:last', this).removeClass('normal-item').addClass('exlusive-item') }); // A listener on the checkboxes $('input[type="checkbox"]', thisQuestion).on('change', function (event) { handleExclusive($(this).closest('td')); }); function handleExclusive(thisCell) { var thisRow = $(thisCell).closest('tr'); // Uncheck the appropriate boxes in a row if ($(thisCell).hasClass('normal-item')) { $('.exlusive-item input[type="checkbox"]', thisRow).prop('checked', false); } else { $('.normal-item input[type="checkbox"]', thisRow).prop('checked', false); } // Check conditions (relevance) $('td.checkbox-item', thisRow).each(function(i) { var thisValue = ''; if($('input[type="checkbox"]', this).is(':checked')) { thisValue = 1; } var thisSGQA = $('input[type="checkbox"]', this).attr('id').replace(/cbox_/, ''); $('input[type="hidden"]', this).attr('value', thisValue); fixnum_checkconditions(thisValue, thisSGQA, 'hidden'); }); } } </script>
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- xueting
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 57
- Thank you received: 0
2 years 11 months ago #216562
by xueting
Replied by xueting on topic Insert a row as answer options in choice task table for Multiple Choice question
It works well!
Thank you again for everything you’ve done. It means a lot to me.
I wish you a nice weekend.
Xueting
Thank you again for everything you’ve done. It means a lot to me.
I wish you a nice weekend.
Xueting
The topic has been locked.
- xueting
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 57
- Thank you received: 0
2 years 10 months ago - 2 years 10 months ago #216775
by xueting
Replied by xueting on topic Insert a row as answer options in choice task table for Multiple Choice question
Hi Joffm,
A new question is whether it's possible to adjust the width of the options here? It seems the widths are evenly distributed except the first column of sub-question.
I also saw in the manual book, it says for the type of array(numbers), the width of the subquestion text can be set, however, the remaining width will be equally divided between the answer options.
Besides, I noticed you once said "with a second snippet (javascript + css) the column widths can be defined"in another question ( forums.limesurvey.org/forum/design-issue...question-loop#213770 ). The thing is this question is for a Array question, and it didn't work with my case (Array(numbers)).
Thank you in advance,
Xueting
A new question is whether it's possible to adjust the width of the options here? It seems the widths are evenly distributed except the first column of sub-question.
I also saw in the manual book, it says for the type of array(numbers), the width of the subquestion text can be set, however, the remaining width will be equally divided between the answer options.
Besides, I noticed you once said "with a second snippet (javascript + css) the column widths can be defined"in another question ( forums.limesurvey.org/forum/design-issue...question-loop#213770 ). The thing is this question is for a Array question, and it didn't work with my case (Array(numbers)).
Thank you in advance,
Xueting
Last edit: 2 years 10 months ago by xueting.
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12930
- Thank you received: 3978
2 years 10 months ago - 2 years 10 months ago #216777
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Insert a row as answer options in choice task table for Multiple Choice question
Hi,
of course it works in an array(numbers).
But in your case it does not.
This is easy to understand.
You do not display the header of the array. This line in the css .ls-heading { display:none; }
So instead of using the "thead" to define the column widths you can use "tr".
Joffm
of course it works in an array(numbers).
But in your case it does not.
This is easy to understand.
You do not display the header of the array. This line in the css .ls-heading { display:none; }
So instead of using the "thead" to define the column widths you can use "tr".
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 2 years 10 months ago by Joffm.
The topic has been locked.
- xueting
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 57
- Thank you received: 0
2 years 10 months ago #216817
by xueting
Replied by xueting on topic Insert a row as answer options in choice task table for Multiple Choice question
Thanks Joffm for your prompt reply. It works! Really appreciate your help!
Best wishes, Xueting
Best wishes, Xueting
The topic has been locked.
- xueting
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 57
- Thank you received: 0
2 years 10 months ago - 2 years 10 months ago #216946
by xueting
Replied by xueting on topic Insert a row as answer options in choice task table for Multiple Choice question
Good afternoon Joffm,A new question is can I make a new question where the options are the chosen answers in the multiple choice task above?For instance, as the following picture shows, option 2, 3, and 4 were chosen in the multiple choice task, then I will be faced with a question asking me to make a choice between option 2, 3, 4 and nothing.
Many thanks!Xueting
Many thanks!Xueting
Last edit: 2 years 10 months ago by xueting.
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12930
- Thank you received: 3978
2 years 10 months ago - 2 years 10 months ago #216947
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Insert a row as answer options in choice task table for Multiple Choice question
Hi,
it's the usual way, that is described here many times.
Between your "choice" question and this new "single" question insert a (hidden) "multiple" question (MHidden) with the seven options as subquestions.
And also a (hidden) question of type "equation" where you preset the subquestions in the "multiple" question according to the selections in the "choice" question.
{MHidden_1=if(M2_SQ001_SQ001==1,"Y","")}
{MHidden_2=if(M2_SQ001_SQ002==1,"Y","")}
{MHidden_3=if(M2_SQ001_SQ003==1,"Y","")}
{MHidden_4=if(M2_SQ001_SQ004==1,"Y","")}
{MHidden_5=if(M2_SQ001_SQ005==1,"Y","")}
{MHidden_6=if(M2_SQ001_SQ006==1,"Y","")}
{MHidden_7=if(M2_SQ001_SQ007==1,"Y","")}
You see, I coded the subquestions "1", "2", ...
And exactly these codes you have to use in the "single" question
Now you use "MHidden" as array filter for your "single" question.
Of course you will not display this "single" question if there was only one option selected.
Joffm
it's the usual way, that is described here many times.
Between your "choice" question and this new "single" question insert a (hidden) "multiple" question (MHidden) with the seven options as subquestions.
And also a (hidden) question of type "equation" where you preset the subquestions in the "multiple" question according to the selections in the "choice" question.
{MHidden_1=if(M2_SQ001_SQ001==1,"Y","")}
{MHidden_2=if(M2_SQ001_SQ002==1,"Y","")}
{MHidden_3=if(M2_SQ001_SQ003==1,"Y","")}
{MHidden_4=if(M2_SQ001_SQ004==1,"Y","")}
{MHidden_5=if(M2_SQ001_SQ005==1,"Y","")}
{MHidden_6=if(M2_SQ001_SQ006==1,"Y","")}
{MHidden_7=if(M2_SQ001_SQ007==1,"Y","")}
You see, I coded the subquestions "1", "2", ...
And exactly these codes you have to use in the "single" question
Now you use "MHidden" as array filter for your "single" question.
Of course you will not display this "single" question if there was only one option selected.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 2 years 10 months ago by Joffm.
The topic has been locked.