- Posts: 4
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
HTTP 403 is an HTTP status code meaning access to the requested resource is forbidden.
Please Log in to join the conversation.
Please Log in to join the conversation.
This small script, placed in the source of a multiple-choice question, will render various answer items as exclusive by disabling other exclusive items.There might be more solutions by javascript, which disable a subquestion if the other one was selected.
<script type="text/javascript" data-author="Tony Partner"> $(document).on('ready pjax:scriptcomplete',function(){ // Define the exclusive sub-question codes var exclusiveCodes = [ 'SQ001', 'SQ002' ]; // Identify this question var qID = '{QID}'; var thisQuestion = $('#question'+qID); // Add some classes $.each(exclusiveCodes, function(i, code) { $(':checkbox[id$="X'+qID+code+'"]', thisQuestion).addClass('exclusive-input'); }); // Listener on the exclusive items $(':checkbox.exclusive-input', thisQuestion).on('change', function(e) { handleExclusive(thisQuestion); }); // Returning to the page handleExclusive(thisQuestion); }); // A function to handle the exclusive items function handleExclusive(thisQuestion) { $(':checkbox.exclusive-input', thisQuestion).prop('disabled', false); if($(':checkbox.exclusive-input:checked', thisQuestion).length > 0) { $(':checkbox.exclusive-input:not(:checked)', thisQuestion).prop('disabled', true); } } </script>
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.