If you want to filter a list-dropdown by the value of a previous equation question, you can use a script something like below.
This script gets the two-character value of a previous equation question with code "
Q2" and removes all answer options that do not have codes starting with those two characters.
Code:
<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>
The script would be similar for filtering by a token attribute but you would replace:
Code:
var filterValue = '{Q2}';
With something like:
Code:
var filterValue = '{TOKEN:ATTRIBUTE_1}';
Sample survey attached: