- Posts: 5
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Last Option In Array (Numbers) (Checkboxes) Column Excludes All Others
- tarantel999
- Topic Author
- Offline
- New Member
Less
More
8 years 2 months ago #131738
by tarantel999
Last Option In Array (Numbers) (Checkboxes) Column Excludes All Others was created by tarantel999
There was a good solution for using exclusive option in checkbox array with forcing the last row to act as exclusive. Is there an easy fix to make it work in columns? So the last row would have exclusive options for the whole column?
Solution for exclusion in rows:
www.limesurvey.org/forum/can-i-do-this-w...-excludes-all-others
Solution for exclusion in rows:
www.limesurvey.org/forum/can-i-do-this-w...-excludes-all-others
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3593
8 years 2 months ago #131746
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 Last Option In Array (Numbers) (Checkboxes) Column Excludes All Others
What version of LimeSurvey are you using?
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- tarantel999
- Topic Author
- Offline
- New Member
Less
More
- Posts: 5
- Thank you received: 0
8 years 2 months ago #131747
by tarantel999
Replied by tarantel999 on topic Last Option In Array (Numbers) (Checkboxes) Column Excludes All Others
2.05 mostly, tried 2.50 today hoping that it would solve it
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3593
8 years 2 months ago #131748
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 Last Option In Array (Numbers) (Checkboxes) Column Excludes All Others
Okay, this should work for 2.05 - 2.50.
Sample survey attached:
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify this question var thisQuestion = $('#question{QID}'); // Assign row-specific classes $('tr.subquestions-list:not(:last) td.question-item', thisQuestion).addClass('non-exclusive'); $('tr.subquestions-list:last td.question-item', thisQuestion).addClass('exclusive'); // Assign column-specific classes $('tr.subquestions-list', thisQuestion).each(function(i){ $('> *', this).each(function(i){ $(this).addClass('column-'+i+''); $(this).attr('data-column', i); }); }); // Listener on the checkboxes $('input[type="checkbox"]', thisQuestion).on('change', function(e) { if($(this).is(':checked')) { var columnNum = $(this).closest('td').attr('data-column'); if($(this).closest('td').hasClass('exclusive')) { $('td[data-column="'+columnNum+'"].non-exclusive input[type="checkbox"]', thisQuestion).prop('checked', false); $('td[data-column="'+columnNum+'"].non-exclusive input:hidden', thisQuestion).attr('value', ''); } else { $('td[data-column="'+columnNum+'"].exclusive input[type="checkbox"]', thisQuestion).prop('checked', false); $('td[data-column="'+columnNum+'"].exclusive input:hidden', thisQuestion).attr('value', ''); } // Check relevance $('td[data-column="'+columnNum+'"] input[id^="answer"]', thisQuestion).each(function(i) { fixnum_checkconditions($(this).attr('value'), $(this).attr('id').replace(/answer/, ''), 'hidden'); }); } }); }); </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.
- tarantel999
- Topic Author
- Offline
- New Member
Less
More
- Posts: 5
- Thank you received: 0
8 years 2 months ago #131814
by tarantel999
Replied by tarantel999 on topic Last Option In Array (Numbers) (Checkboxes) Column Excludes All Others
Huge thanks!
The topic has been locked.