Yes.
Code:
<script type="text/javascript" charset="utf-8">
$(document).on('ready pjax:scriptcomplete',function(){
var thisQuestion = $('#question{QID}');
// Insert selects into column 2
$(' .answer_cell_c', thisQuestion).addClass('with-select').append('<select class="inserted-select form-control list-question-select">\
<option value="">Please select</option>\
<option value="1">Yes</option>\
<option value="2">No</option>\
</select>');
// Insert selects into column 3
$(' .answer_cell_d', thisQuestion).addClass('with-select').append('<select class="inserted-select form-control list-question-select">\
<option value="">If Yes...</option>\
<option value="1">1</option>\
<option value="2">2</option>\
<option value="3">3</option>\
</select>');
// Listeners on select elements
$('.inserted-select', thisQuestion).on('change', function(i) {
if($(this).val() != '') {
$(this).closest('.answer-item').find('input:text').val($.trim($('option:selected', this).text())).trigger('change');
}
else {
$(this).closest('.answer-item').find('input:text').val('').trigger('change');
}
// 3rd column conditional on 2nd column
if($(this).closest('.answer-item').hasClass('answer_cell_c')) {
handleColumn3($(this));
}
});
function handleColumn3(thisSelect) {
var thisRow = $(thisSelect).closest('tr.subquestion-list');
var item3 = $('.answer_cell_d', thisRow);
if($(thisSelect).val() == '1') {
$('.inserted-select', item3).prop('disabled', false);
}
else {
$('.inserted-select', item3).val('').prop('disabled', true);
$('input:text', item3).val('').trigger('change');
}
}
// Returning to page
$('.with-select input:text', thisQuestion).each(function(i) {
var thisCell = $(this).closest('.answer-item');
var inputText = $.trim($(this).val());
var selectval = $('select.inserted-select option', thisCell).filter(function () { return $(this).html() == inputText; }).val();
$('select.inserted-select', thisCell).val(selectval);
// 3rd column conditional on 2nd column
if($(this).closest('.answer-item').hasClass('answer_cell_c')) {
handleColumn3($('select.inserted-select', thisCell));
}
});
// Clean-up styles
$('select.inserted-select', thisQuestion).css({
'max-width': '100%'
});
$('.with-select input:text', thisQuestion).css({
'position': 'absolute',
'left': '-9999em'
});
});
</script>