- Posts: 162
- Thank you received: 14
Ask the community, share ideas, and connect with other LimeSurvey users!
/****************************************** * Begin DISC manipulation script ******************************************/ function shuffleArray(array) { for (var i = array.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); var temp = array[i]; array[i] = array[j]; array[j] = temp; } return array; } $(document).on('ready pjax:complete',function() { // Identify this question var thisQuestion = $('.array-flexible-column:eq(0)'); var elements = $('tr.answers-list', thisQuestion).detach().toArray(); shuffleArray(elements); $('tr.answers-list', thisQuestion).remove(); $.each(elements, function(i, el) { $('table.subquestion-list tbody:eq(0)', thisQuestion).append(el); }); }); $(document).ready(function() { // Identify the questions -- FOR DISC var thisQuestion = $('[id^=question]'); // Listener on the radios $('input.radio', thisQuestion).on('click', function(e) { $('input[type="radio"]', thisQuestion).prop('disabled', false); $('input.radio:checked', thisQuestion).each(function(i) { $(this).closest('tr.answers-list').find('input[type="radio"]').not(this).prop('disabled', true); }); }); // Initial settings $('input.radio:checked', thisQuestion).each(function(i) { $(this).closest('tr.answers-list').find('input[type="radio"]').not(this).prop('disabled', true); }); }); /****************************************** * End DISC manipulation script ******************************************/
$('input.radio', thisQuestion).on('click', function(e) {
<input class="radio" type="radio" name="451344X410X7685SM" value="D1" id="answer451344X410X7685SM-D1" onclick="checkconditions(this.value, this.name, this.type)">
<input type="radio" name="186194X76X854SM" value="S1" id="answer186194X76X854SM-S1">
$(document).on('ready pjax:complete',function() { // Identify the questions -- FOR DISC var thisQuestion = $('.array-flexible-column:eq(0)'); function handleRadios() { $('input:radio', thisQuestion).prop('disabled', false); $('.disabled-item', thisQuestion).removeClass('disabled-item'); $('input:radio:checked', thisQuestion).each(function(i) { var thisRow = $(this).closest('tr.answers-list'); var otherRadios = $('input:radio', thisRow).not(this); $(otherRadios).prop('disabled', true); $(otherRadios).closest('td').addClass('disabled-item'); }); } // Listener on the radios $('input:radio', thisQuestion).on('click', function(e) { handleRadios(); }); // Initial settings handleRadios(); });
.disabled-item { cursor:not-allowed !important; }