- Posts: 19
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
<script type="text/javascript" data-author="Tony Partner"> $(document).on('ready pjax:scriptcomplete',function(){ // Identify this question var qID = '{QID}'; var thisQuestion = $('#question'+qID); var exclusiveRow = $('tr[id^="javatbd"]:last', thisQuestion); var normalRows = $('tr[id^="javatbd"]', thisQuestion).not(exclusiveRow); // The value to be loaded in the exclusive inputs var exclusiveVal = '1'; // Index the array columns $('table.subquestion-list tr', thisQuestion).each(function(i) { $('> *', this).each(function(i) { $(this).attr('data-index', i); }); }); // Hide the last-row inputs $(':text', exclusiveRow).hide(); // Insert the check-boxes $('.answer-item', exclusiveRow).each(function(i) { var thisIndex = $(this).attr('data-index'); $(this).addClass('with-inserted-checkbox').append('<span class="checkbox-item">\ <input type="checkbox" name="insertedInput'+thisIndex+'" id="insertedInput'+thisIndex+'" value="" />\ <label for="insertedInput'+thisIndex+'" class="checkbox-label control-label"></label>\ </span>'); }); // A listener on the normal text inputs $('input[type="text"]', normalRows).on('change keyup', function (event) { if($.trim($(this).val()) != '') { var thisCell = $(this).closest('.answer-item'); var thisIndex = $(thisCell).attr('data-index'); $('.answer-item[data-index="'+thisIndex+'"] input[type="hidden"]', exclusiveRow).val(''); $('.answer-item[data-index="'+thisIndex+'"] :text', exclusiveRow).val('').trigger('keyup'); $('.answer-item[data-index="'+thisIndex+'"] :checkbox', exclusiveRow).prop('checked', false); } }); // Listener on the exclusive checkboxes $(':checkbox', exclusiveRow).on('change', function (event) { if($(this).is(':checked')) { var thisCell = $(this).closest('.answer-item'); var thisIndex = $(thisCell).attr('data-index'); $('.answer-item[data-index="'+thisIndex+'"] input[type="hidden"]', normalRows).val(''); $('.answer-item[data-index="'+thisIndex+'"] :text', normalRows).val('').trigger('keyup'); $(':text', thisCell).val(exclusiveVal).trigger('keyup'); } else { $(':text', thisCell).val('').trigger('keyup'); } }); }); </script>
<style type="text/css" data-author="Tony Partner"> #question{QID} td.with-inserted-checkbox label::before, #question{QID} td.with-inserted-checkbox label::after { margin-top: -8px; } </style>
Please Log in to join the conversation.