- Posts: 85
- Thank you received: 9
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ // Identify this question var thisQuestion = $('#question{QID}'); // Assign column-specific classes $('table.subquestion-list tr', thisQuestion).each(function(i) { $('> *:gt(0)', this).each(function(i){ $(this).addClass('column-'+(i+1)); $(this).attr('data-column', i+1); }); }); // Hide the text inputs in columns 1 and 4 $('.column-1 input[type="text"]', thisQuestion).hide(); // Insert the checkboxes into column 1 $('.answer-item.column-1').append('<input type="checkbox" Style="height:28px;Width:28px; display: initial;"/>'); // Initial checkbox states (if the question has already been answered) $('.answer-item.column-1 input[type="text"]').each(function(i){ if($.trim($(this).val()) == 'Y') { $(this).closest('td').find('.inserted-checkbox').attr('checked', true); } }); // Listener on the checkboxes (insert "Y" into hidden text input when checked) $('.inserted-checkbox').change(function() { if($(this).is(':checked')) { $(this).closest('td').find('input[type="text"]').val('Y'); } else { $(this).closest('td').find('input[type="text"]').val(''); } }); }); </script>
Please Log in to join the conversation.
Please Log in to join the conversation.