I think the solution here is to insert a hidden multiple-choice question after Q1 (on the same page), and use JavaScript to toggle the check-boxes depending on answers in Q1. Q2 can then be filtered by the hidden question regardless of where it is in the survey.
1) Insert a multiple-choice directly after Q1. This question has identical sub-questions and sub-questions codes as Q1
2) Insert this script into the source of Q1. Adjust "filterColumns" as required.
Code:
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
// Define the filtering columns
var filterColumns = [2, 3];
// Identify the questions
var q1 = $('#question{QID}');
var qHidden = $(q1).nextAll('.multiple-opt:eq(0)');
// Define a few vars
var q1ID = $(q1).attr('id').replace(/question/, '');
var qHiddenID = $(qHidden).attr('id').replace(/question/, '');
// Hide the multiple-choice
$(qHidden).hide();
// Assign some classes
$('table.question tbody[id^=javatbd] tr', q1).each(function(i){
$('> td', this).each(function(i){
$(this).addClass('column-'+(i+1)+'');
});
});
$(filterColumns).each(function(i){
$('td.column-'+this+'').addClass('filter-cell');
});
// Listener on the Q1 cells
$('table.question tbody[id^=javatbd] td', q1).click(function(e) {
var thisRow = $(this).closest('tbody');
var thisCode = $(thisRow).attr('id').split('X'+q1ID)[1];
var hiddenInput = $('input.checkbox[id$="X'+qHiddenID+thisCode+'"]', qHidden);
setTimeout(function() {
if($('input.radio:checked', thisRow).closest('td').hasClass('filter-cell')) {
$(hiddenInput).attr('checked', true);
$(hiddenInput).nextAll('input[type="hidden"]').attr('value', 'Y');
}
else {
$(hiddenInput).attr('checked', false);
$(hiddenInput).nextAll('input[type="hidden"]').attr('value', '');
}
// Check conditions/relevance
checkconditions(hiddenInput.value, hiddenInput.name, hiddenInput.type)
}, 250);
});
});
</script>
3) Filter Q2 by the hidden question.
Sample survey attached: