- Posts: 153
- Thank you received: 8
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function() { $('input:checkbox').on('change', function(i) { if($(this).is(':checked')) { // Identifyy some stuff... var thisQuestion = $(this).closest('.multiple-opt'); var thisQID = thisQuestion.attr('id').replace(/question/, ''); var otherQuestion = $('.multiple-opt').not(thisQuestion).first(); var otherQID = otherQuestion.attr('id').replace(/question/, ''); var thisCode = $(this).attr('id').split('X'+thisQID)[1]; // Uncheck the check-box in the other question $('input:checkbox[id$="X'+otherQID+thisCode+'"]').prop('checked', false).trigger('change'); $('input:hidden[id^="java"][id$="X'+otherQID+thisCode+'"]').val(''); } }); }); </script>
... $('input:checkbox').on('change', function(i) { if($(this).is(':checked')) //...&& is/has a variable with the name secondaryRows// { ...
secondaryRows.css({ 'margin-left':'2.5em' });
secondaryRows.addClass('secondary-item').css({ 'margin-left':'2.5em' });
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function() { // Add classes and attributes $('li.question-item').closest('ul').addClass('inserted-question-list'); $('li.question-item').each(function(i) { $(this).attr('data-index', $(this).index()); }); $('body').on('change', '.secondary-item input:checkbox', function(i) { if($(this).is(':checked')) { // Identify some stuff... var thisQuestion = $(this).closest('.multiple-opt'); var thisList = $(this).closest('ul.inserted-question-list'); var otherList = $('.inserted-question-list', thisQuestion).not(thisList).first(); var thisIndex = $(this).closest('li').attr('data-index'); var otherItem = $('li[data-index="'+thisIndex+'"]', otherList); // Uncheck the check-box in the other question $('input:checkbox', otherItem).prop('checked', false).trigger('change'); $('input:hidden', otherItem).val(''); } }); }); </script>