- Posts: 19
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ var thisQuestion = $('#question{QID}'); // Remove some text inputs $('.checkbox-text-item:eq(0) .comment-item', thisQuestion).remove(); $('.checkbox-text-item:eq(1) .comment-item', thisQuestion).remove(); $('.checkbox-text-item:last .comment-item', thisQuestion).remove(); // Listener on the checkboxes (exclude all other checkboxes) $('.checkbox-text-item :checkbox', thisQuestion).on('change', function(e) { if($(this).is(':checked')) { $('.checkbox-text-item :checkbox', thisQuestion).not(this).each(function(i) { $(this).prop('checked', false); $(this).nextAll('input:hidden').val(''); $(this).closest('li').find('input:text').val('').trigger('keyup'); }); $('input.other-text', thisQuestion).val('').trigger('keyup'); } }); // Listener on the "Other" input (exclude all other checkboxes) $('input.other-text', thisQuestion).on('keyup change', function(e) { if($.trim($(this).val()) != '') { $('.checkbox-text-item :checkbox', thisQuestion).each(function(i) { $(this).prop('checked', false); $(this).nextAll('input:hidden').val(''); $(this).closest('li').find('input:text').val('').trigger('keyup'); }); } }); }); </script>