- Posts: 6
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
<script> (function( $ ){ $.fn.cbExclusiveColumns = function(options) { var opts = $.extend( { }, options); return this.each(function() { var thisQuestion = $(this) $('td.answer-item', thisQuestion).addClass('normal-item'); $('tr.subquestion-list', thisQuestion).each(function(i) { var thisRow = $(this); $.each(opts.columns, function(i, val) { $('td.answer-item:eq('+(val-1)+')', thisRow).removeClass('normal-item').addClass('exclusive-item'); }); }); $('input[type="checkbox"]', thisQuestion).on('change', function (event) { handleExclusive($(this).closest('td')); }); function handleExclusive(thisCell) { var thisRow = $(thisCell).closest('tr'); if ($(thisCell).hasClass('normal-item')) { $('.exclusive-item input[type="checkbox"]', thisRow).prop('checked', false); $('.exclusive-item input[type="text"]', thisRow).val(''); } else { $('.answer-item', thisRow).not(thisCell).find('input[type="checkbox"]').prop('checked', false); $('.answer-item', thisRow).not(thisCell).find('input[type="text"]').val(''); } $('td.answer-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'); }); } }); }; })( jQuery ); </script><script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ $('#question[b]{QID}').cbExclusiveColumns({ columns: [9, 10, 11, 12] // Hier die Positionen der exklusiven Spalten eintragen }); });[/b] </script>