- Posts: 54
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Array with numbers
- nibos
- Topic Author
- Offline
- Senior Member
Less
More
8 years 3 months ago #130087
by nibos
Array with numbers was created by nibos
Attachments:
The topic has been locked.
- StefanBasen
- Offline
- Junior Member
Less
More
- Posts: 39
- Thank you received: 0
8 years 2 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.
- nibos
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 54
- Thank you received: 0
8 years 2 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.