- Posts: 102
- Thank you received: 2
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Making a row exclusive
- boshra.m
- Topic Author
- Offline
- Premium Member
Less
More
1 year 5 months ago #233647
by boshra.m
Making a row exclusive was created by boshra.m
Please help us help you and fill where relevant:
Your LimeSurvey version: LimeSurvey Cloud Version 5.4.9
Own server or LimeSurvey hosting: LimeSurvey hosting
Survey theme/template: Fruity
==================
Hello,
I was wondering if it was possible to make a row exclusive in an array numbers, checkbox question? Specifically, is it possible that if a respondent selects the last row ("Not applicable (meal option not offered at your school)" in question 2.5), the rest of the column is blocked off or cleared out (similarly done for question 1.1)?
I was able to do something similar for columns where if they selected either None or Unsure, then they cannot select the first three columns (question 2.5).
Just wondering if this is possible.
Thank you.
Your LimeSurvey version: LimeSurvey Cloud Version 5.4.9
Own server or LimeSurvey hosting: LimeSurvey hosting
Survey theme/template: Fruity
==================
Hello,
I was wondering if it was possible to make a row exclusive in an array numbers, checkbox question? Specifically, is it possible that if a respondent selects the last row ("Not applicable (meal option not offered at your school)" in question 2.5), the rest of the column is blocked off or cleared out (similarly done for question 1.1)?
I was able to do something similar for columns where if they selected either None or Unsure, then they cannot select the first three columns (question 2.5).
Just wondering if this is possible.
Thank you.
Please Log in to join the conversation.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
1 year 5 months ago #233681
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 Making a row exclusive
This little script placed in the question source of an array-numbers-checkboxes question will render the last row exclusive:
Sample survey attached:
Code:
<script type="text/javascript" data-author="Tony Partner"> $(document).on('ready pjax:scriptcomplete',function(){ // Identify this question var thisQuestion = $('#question{QID}'); // Identify the exclusive row var thisTable = $('table.subquestion-list', thisQuestion); var exclusiveRow = $('tr[id^="javatbd"]:last', thisTable); $(exclusiveRow).addClass('exclusive-row'); // Listener on the checkboxes $(':checkbox', thisTable).on('change', function(event){ if($(this).is(':checked')) { var thisRow = $(this).closest('tr'); // Identify the column var thisIndex = $(this).closest('td').index(); // Identify the radios to be un-checked var excludedItems = $('tr.exclusive-row td.answer-item:nth-child('+(thisIndex+1)+')', thisTable); if($(thisRow).hasClass('exclusive-row')) { excludedItems = $('tr:not(.exclusive-row) td:nth-child('+(thisIndex+1)+')', thisTable); } // Un-check those checkboxes $.each(excludedItems, function(i, thisItem) { $('input[type="hidden"]', thisItem).val(''); $(':checkbox', thisItem).prop('checked', false).trigger('change'); }); } }); }); </script>
Sample survey attached:
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: boshra.m
Please Log in to join the conversation.
- boshra.m
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 102
- Thank you received: 2
1 year 5 months ago #233696
by boshra.m
Replied by boshra.m on topic Making a row exclusive
Thank you thank you!!
Please Log in to join the conversation.
- boshra.m
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 102
- Thank you received: 2
1 year 5 months ago #233718
by boshra.m
Replied by boshra.m on topic Making a row exclusive
Ah now I was wondering however instead of making it so that the respondent has to check at least one box per row, how would I go about making it that they have to check one box per column?
I would do array but column but I need the checkbox layout.
Thank you!!
I would do array but column but I need the checkbox layout.
Thank you!!
Please Log in to join the conversation.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
1 year 5 months ago #233726
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 Making a row exclusive
This has nothing to do with "Making a row exclusive". Please open a new thread for new topics.
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: boshra.m
Please Log in to join the conversation.
- LeldeAv
- Offline
- New Member
Less
More
- Posts: 5
- Thank you received: 0
1 year 2 months ago #240080
by LeldeAv
Replied by LeldeAv on topic Making a row exclusive
What modifications would I need to make to this script in order to get the same result but for last column?
Please Log in to join the conversation.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12940
- Thank you received: 3979
1 year 2 months ago #240094
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Making a row exclusive
Just read the manual
[url] manual.limesurvey.org/Workarounds:_Manip..._Excludes_All_Others [/url]
Joffm
[url] manual.limesurvey.org/Workarounds:_Manip..._Excludes_All_Others [/url]
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Please Log in to join the conversation.