Hi,
this is really a very very old script.
Why don't you use an array(text) with dropdowns?
Many times shown here in the forum.
And with subquestion relevance you display row by row
Row 2: !is_empty(self.sq_Y001_X001) and !is_empty(self.sq_Y001_X002)
Row 3: !is_empty(self.sq_Y002_X001) and !is_empty(self.sq_Y002_X002)
...
Code:
<script type="text/javascript" charset="utf-8">
$(document).on('ready pjax:scriptcomplete',function(){
var thisQuestion = $('#question{QID}');
// Insert selects
$('.answer-item.answer_cell_X002', thisQuestion).addClass('with-select').append('<select class="inserted-select form-control list-question-select">\
<option value="">Select...</option>\
<option value="1">Not important at all</option>\
<option value="2">2</option>\
<option value="3">3</option>\
<option value="4">4</option>\
<option value="5">Very important</option>\
<option value="6">Don´t know</option>\
</select>');
// Listeners
$('.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');
}
});
// 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);
});
// Clean-up styles
$('select.inserted-select', thisQuestion).css({
'max-width': '100%'
});
$('.with-select input:text', thisQuestion).css({
'position': 'absolute',
'left': '-9999em'
});
});
</script>
Example without columns of different widths.
There are also some solutions to vary the column widths.
1. javascript
Code:
<script type="text/javascript" charset="utf-8">
$(document).on('ready pjax:scriptcomplete',function(){
// Identify this question
var thisQuestion = $('#question{QID}');
// Add a question class
thisQuestion.addClass('custom-array');
// Column-specific classes
$('table.subquestion-list tr', thisQuestion).each(function(i) {
$('th, td', this).each(function(i) {
$(this).addClass('column-'+i);
});
});
});
</script>
2. css
Code:
<style type="text/css">.custom-array table.subquestion-list col {
width: auto !important;
}
.custom-array table.subquestion-list thead .column-0 { width: 5%; }
.custom-array table.subquestion-list thead .column-1 { width: 80%; }
.custom-array table.subquestion-list thead .column-2 { width: 15%; }
</style>
And a code "Don't know", if I am inserting my own items?
Or do you plan a different array?
An array with precodes AND additional others to rate?
Like this?
Joffm