Assuming you can place the filter question on a previous page, you can place this script in the source of a list-radio question.
- Hide the radio list.
- Insert a drop-down containing only the relevant radio items.
Code:
<script type="text/javascript" data-author="Tony Partner">
$(document).on('ready pjax:scriptcomplete',function(){
// Identify this question
var qID = '{QID}';
var thisQuestion = $('#question'+qID);
// Hide the radios
$('.answers-list', thisQuestion).hide();
// Need a small delay to allow EM to set the radio relevance
setTimeout(function() {
// Insert the drop-down
$('.answers-list', thisQuestion).after('<div class="form-inline">\
<div class="ls-answers answer-item dropdown-item form-group">\
<select class="form-control list-question-select inserted-select">\
<option value="">Please choose...</option>\
</select>\
</div>\
</div>');
// Insert the list options
$('.radio-item:not(.ls-irrelevant) :radio', thisQuestion).each(function(i) {
var thisVal = $(this).val();
var thisLabel = $(this).next('label').html();
$('.inserted-select', thisQuestion).append('<option value="'+thisVal+'">'+thisLabel+'</option>');
});
// Listener on the drop-down
$('.inserted-select', thisQuestion).on('change', function(e) {
var thisVal = $(this).val();
var checkedRadio = $('.radio-item :radio[id$="'+qID+thisVal+'"]', thisQuestion);
// Click the corresponding radio
$(checkedRadio).trigger('click');
// Fire ExpressionScript
checkconditions($(checkedRadio).attr('value'), $(checkedRadio).attr('name'), 'radio');
});
// Returning to the page
if($('.radio-item :radio:checked', thisQuestion).length > 0) {
var questionVal = $('.radio-item :radio:checked:eq(0)', thisQuestion).val();
$('.inserted-select', thisQuestion).val(questionVal);
}
}, 500);
});
</script>