Yes, I have setted up my survey to use JavaScript, but when I place the following script, it doesn't block the other possible answers.
<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('normalOpt');
$('tr.subquestions-list', thisQuestion).each(function(i) {
$('.normalOpt:first', this).removeClass('normalOpt').addClass('exlusiveOpt')
});
// A listener on the checkbox cells
$('td.checkbox-item', thisQuestion).click(function (event) {
handleExclusive($(this));
});
// A listener on the checkboxes
$('td.checkbox-item input[type="checkbox"]', thisQuestion).click(function (event) {
handleExclusive($(this).closest('td'));
});
function handleExclusive(thisCell) {
var thisRow = $(thisCell).closest('tr');
// Uncheck the appropriate boxes in a row
if ($(thisCell).hasClass('normalOpt')) {
$('.exlusiveOpt input[type="checkbox"]', thisRow).attr('checked', false);
}
else {
$('.normalOpt input[type="checkbox"]', thisRow).attr('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>
The topic has been locked.