- Posts: 139
- 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.
Please Log in to join the conversation.
Please Log in to join the conversation.
var questionContainer = $('#question{QID}'); // Find all the checkboxes within the question container var checkboxes = questionContainer.find('input[type="checkbox"]'); // Filter out the fixed checkboxes (2 and 5) and store their values var fixedCheckboxes = ; checkboxes.each(function() { var checkbox = $(this); var checkboxValue = parseInt(checkbox.val()); if (checkboxValue === 2 || checkboxValue === 5) { fixedCheckboxes.push(checkbox); } }); // Remove the fixed checkboxes from the list checkboxes = checkboxes.not(fixedCheckboxes); // Shuffle the remaining checkboxes checkboxes.sort(function() { return Math.random() - 0.5; }); // Insert the fixed checkboxes at their respective positions questionContainer.find('input[type="checkbox"]').slice(0, 0).before(fixedCheckboxes[0]); questionContainer.find('input[type="checkbox"]').slice(3, 3).before(fixedCheckboxes[1]);
Please Log in to join the conversation.
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { var SubHeading1="Header 1"; var SubHeading2="Header 2"; var thisQuestion = $('#question{QID}'); // Insert sub-headings $('.checkbox-item:eq(0)', thisQuestion).before('<li class="inserted-sub-heading"><span class="myHeader">'+SubHeading1+'</span></li>'); $('.checkbox-item:eq(4)', thisQuestion).before('<li class="inserted-sub-heading"><span class="myHeader">'+SubHeading2+'</span></li>'); }); </script> <style type="text/css">.myHeader { color:maroon; font-size:100%; font-weight:bold; background-color:#F8F8FF; border:1px solid #ccc; padding: 1px 5px; }