- Posts: 930
- Thank you received: 221
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify this question var thisQuestion = $('#question{QID}'); var chooseText = 'Please choose...'; // Get the filtering value var filterValue = '{Q2}'; // Handle previous answers var selectVal = $.trim($('.answer-item select', thisQuestion).val()); if(selectVal != '' && selectVal.substr(0, 2).toUpperCase() != filterValue) { $('.answer-item select', thisQuestion).prepend('<option value="">'+chooseText+'</option>').val('').trigger('change'); } // Loop through all dropdown options and remove those with codes not starting with the filterValue $('.answer-item select option', thisQuestion).each(function(i){ if($(this).attr('value') && $(this).attr('value').substr(0, 2).toUpperCase() != filterValue) { $(this).remove(); } }); }); </script>
var filterValue = '{Q2}';
var filterValue = '{TOKEN:ATTRIBUTE_1}';
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify this question var thisQuestion = $('#question{QID}'); var chooseText = 'Please choose...'; // Get the filtering value var filterValue = '{Q2}'; // Handle previous answers var selectVal = $.trim($('.answer-item select', thisQuestion).val()); if(selectVal != '' && selectVal != '-oth-' && selectVal.substr(0, 2).toUpperCase() != filterValue) { $('.answer-item select', thisQuestion).prepend('<option value="">'+chooseText+'</option>').val('').trigger('change'); } // Loop through all dropdown options and remove those with codes not starting with the filterValue $('.answer-item select option', thisQuestion).each(function(i){ if($(this).attr('value') && $(this).attr('value') != '-oth-' && $(this).attr('value').substr(0, 2).toUpperCase() != filterValue) { $(this).remove(); } }); }); </script>