Your LimeSurvey version:
LimeSurvey Cloud
Version 6.3.0
==================
Hi everyone,
I have a question with an Array with checkboxes, and I want to make the last one exclusive. I found several topics in the forums relating to this, but none works. I also checked the manual and any material related.
The last code I tried is this one:
<script type="text/javascript" charset="utf-8">
$(document).on('ready pjax:scriptcomplete',function(){
var thisQuestion = $('#question{QID}')
// Add some classes to the checkbox cells
$('td.checkbox-item:last-child', thisQuestion).addClass('exclusive-item');
// A function to un-check boxes
function resetCheckbox(thisItem) {
$(':hidden', thisItem).val('');
$(':checkbox', thisItem).prop('checked', false).trigger('change');
}
// A listener on the checkboxes
$(':checkbox', thisQuestion).on('change', function(e) {
if($(this).is(':checked')) {
var thisItem = $(this).closest('.answer-item');
var thisRow = $(this).closest('tr');
var items = $('td.answer-item.exclusive-item', thisRow);
if($(thisItem).hasClass('exclusive-item')) {
items = $('td.answer-item:not(.exclusive-item)', thisRow);
}
$.each(items, function(i, el) {
resetCheckbox(el);
});
}
});
});
</script>
Find the sample question in the file attached.
I hope someone can help. I'm not fluent in java to do any huge changes in the code. I also tried to adjust all options I could find, but still not working.
Thank you very much,
Best