- Posts: 20
- Thank you received: 3
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ // Identify this question var thisQuestion = $('#question{QID}'); // Listener on the radios $('input:radio', thisQuestion).on('click', function(e) { // Identify some elements/vars var thisRow = $(this).closest('tr.answers-list'); var thisInput = $(this); var thisName = thisInput.attr('name'); var otherInput = $('input:radio', thisRow).not('[name="'+thisName+'"]').first(); // Uncheck other radios in this row $('input:radio', thisRow).not(thisInput).prop('checked', false); // Fire expression manager on the unchecked radios var otherName = otherInput.attr('name').replace('#', '_'); $('#java'+otherName).val(''); ExprMgr_process_relevance_and_tailoring('change', otherName, 'radio'); // Check for answered rows if($('input:radio:checked', thisQuestion).length == $('tr.answers-list', thisQuestion).length) { $(thisQuestion).removeClass('input-error'); } }); // Interrupt the submit and check for answered rows $('#ls-button-submit').on('click', function(e) { if($('input:radio:checked', thisQuestion).length != $('tr.answers-list', thisQuestion).length) { $(thisQuestion).addClass('input-error'); alert('Please answer all rows.'); e.preventDefault(); return false; } }); }); </script>