Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Array with numbers

More
10 years 8 months ago #130087 by nibos
Array with numbers was created by nibos
I have this array with numbers as drop menu. How can I include checkbox on the last column in case the user must not answer Q1,Q2 or Q3 and just select "Not included"?

Also is there a way to add an extra, common label heading above the "Q1"...."Not included"?

Thank you in advance
The topic has been locked.
More
10 years 7 months ago #130588 by StefanBasen
Replied by StefanBasen on topic Array with numbers
This here should help with that Checkbox Issue
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { var thisQuestion = $('#question{QID}'); var noAnswer = 99999; // Add some classes to the answer cells $('td.question-item', thisQuestion).addClass('normal-opt'); $('td.question-item:last-child', thisQuestion).removeClass('normal-opt').addClass('exlusive-opt') $('.exlusive-opt select', thisQuestion).hide(); $('.exlusive-opt', thisQuestion).append('<input type="checkbox" class="checkbox">'); $('.exlusive-opt select', thisQuestion).append('<option value="'+noAnswer+'">'+noAnswer+'</option>'); $('.normal-opt select', thisQuestion).on('change', function() { var thisRow = $(this).closest('tr.subquestions-list'); if($(this).val() != ''){ $('.exlusive-opt input[type=checkbox]', thisRow).prop('checked', false); $('.exlusive-opt select', thisRow).val(''); $('.exlusive-opt input[type="hidden"]', thisRow).attr('value', ''); } }); $('.exlusive-opt input[type="checkbox"]', thisQuestion).on('change', function(event) { var thisCell = $(this).closest('td.question-item'); var thisRow = $(this).closest('tr.subquestions-list'); if($(this).is(':checked')) { $('select', thisCell).val(noAnswer); $('input[type="hidden"]', thisCell).attr('value', noAnswer); $('.normal-opt select', thisRow).val(''); $('.normal-opt input[type="hidden"]', thisRow).attr('value', ''); } else { $('.exlusive-opt select', thisRow).val(''); $('.exlusive-opt input[type="hidden"]', thisRow).attr('value', ''); } }); $('.exlusive-opt input[type="hidden"]', thisQuestion).each(function(i) { var thisCell = $(this).closest('td.question-item'); if($(this).attr('value') == noAnswer) { $('input[type=checkbox]', thisCell).prop('checked', true); $('select', thisCell).val(noAnswer); } }); }); </script>
The topic has been locked.
More
10 years 7 months ago #130655 by nibos
Replied by nibos on topic Array with numbers
Thank you very much. It works fine. :)
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose