- Posts: 8
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify the questions and IDs var q1ID = {QID}; var q1 = $('#question'+q1ID); var qHidden = q1.nextAll('.multiple-opt:eq(0)'); var qHiddenID = qHidden.attr('id').replace(/question/, ''); // Hide qHidden qHidden.hide(); // Listeners on the Q1 checkboxes $('input.checkbox', q1).change(function(e) { var q1Checkbox = $(this); // Define the food "group" var foodGroup = $(this).attr('id').split('X'+q1ID)[1].substr(0, 4); // Loop through subquestions within the food "group" in qHidden $('input.checkbox[id*="X'+qHiddenID+foodGroup+'"]', qHidden).each(function(i) { // Toggle the checkbox(es) in qHidden $(this).prop('checked', $(q1Checkbox).prop('checked')); $(this).nextAll('input[type="hidden"]:eq(0)').attr('value', $(q1Checkbox).nextAll('input[type="hidden"]:eq(0)').attr('value')); // Fire the Expression Manager checkconditions() function checkconditions(this.value, this.name, this.type); }); }); }); </script>
it will work for both filter and exclusion-filter
Hi,tpartner wrote: I would be inclined to insert a hidden copy of Q2 (call it qHidden) after Q1 and then use JavaScript to toggle the check-boxes in the hidden question. Corresponding food "group" sub-questions can be identified by the first 4 characters of sub-question codes.
Aspirin retail sales will probably plunge...But in 2.06 : we don't need any javascript \o/ : each subquestion have own relevance equation.
Ben_V wrote:
Aspirin retail sales will probably plunge...But in 2.06 : we don't need any javascript \o/ : each subquestion have own relevance equation.