- Posts: 4
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
$(function(){ var $radios = $('input[type="radio"]'); $radios.click(function () { var $this = $(this); if ($this.data('checked')) { this.checked = false; } var $otherRadios = $radios.not($this).filter('[name="' + $this.attr('name') + '"]'); $otherRadios.prop('checked', false).data('checked', false); $this.data('checked', this.checked); }); });
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 thisQuestion = $('#question{QID}'); // A function to toggle radio inputs function toggleRadio(thisCell) { if($(':radio:checked', thisCell).length == 0) { $(':radio', thisCell).trigger('click'); } else { $(':radio:eq(0)', thisCell).prop('checked', false); checkconditions('', $(':radio:eq(0)', thisCell).attr('name'), 'radio'); } } // Listener on the radio inputs $(':radio', thisQuestion).on('click', function(e) { e.stopPropagation(); }); // Listener on the array cells $('.answer-item', thisQuestion).on('click', function(e) { e.stopPropagation(); toggleRadio(this); }); // Listener on the labels $('.answer-item label', thisQuestion).on('click', function(e) { e.preventDefault(); e.stopPropagation(); toggleRadio($(this).closest('.answer-item')); }); }); </script>
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 thisQuestion = $('#question{QID}'); // Listener on the radio inputs $(':radio', thisQuestion).css('left', '-9999em').on('click', function(e) { e.stopPropagation(); }); // Listener on the labels $('.answer-item label', thisQuestion).on('click', function(e) { e.preventDefault(); var thisItem = $(this).closest('.answer-item'); if($(':radio:checked', thisItem).length == 0) { $(':radio', thisItem).trigger('click'); } else { $(':radio:eq(0)', thisItem).prop('checked', false); checkconditions('', $(':radio:eq(0)', thisItem).attr('name'), 'radio'); } }); }); </script>
Please Log in to join the conversation.