Hi!
I just successfully tested the Expandable Array Workaround on LS 2.06LTS - with this workaround it's possible to let appear array questions line by line, where the next line appears when the question on the line before was answered (s.
www.limesurvey.org/manual/Workarounds:_M...ipt#Expandable_Array
) - thanks for this workaround!
I noticed that there is a "problem" when a line of a long array appears at the bottom of the screen: the line appears outside the screen and the respondents have to scroll to see the question. Is there a way to keep the focus on the last line, such that the appearing question is always above the bottom on the screen and can be answered with no scrolling necessary? That would be great! (I think it could work with something like
css-tricks.com/almanac/selectors/n/nth-last-child/
but this is just an uneducated guess.)
Thanks a lot for your hints and solutions!
Best, G
Here comes the code from the
workaround page
:
Code:
<script type="text/javascript">
$(document).ready(function() {
// A function to show subsequent rows of an array as options are checked
function expandingArray(qID) {
// Build an array of the question rows
var arrayRow = '#question' + qID + ' table.question tbody tr';
// Initially hide all rows unless an input was previously checked
$( arrayRow ).each(function(i) {
if ( $( arrayRow + ':eq(' + i + ') input.radio:checked' ).length != 0 ) {
$(this).attr('name', 'clickedRow');
}
else {
$(this).attr('name', 'hidden').hide();
}
});
// Now show the first hidden row
addRow();
// Add another row when an option is checked for the first time
$( '#question' + qID + ' td.answer input.radio' ).click(function (event) {
if ($(this).parents('tr:eq(0)').attr('name') != 'clickedRow') {
addRow();
$(this).parents('tr:eq(0)').attr('name', 'clickedRow');
}
// The original function of the click event
checkconditions(this.value, this.name, this.type);
});
// Add another row when an table cell is clicked for the first time
$( '#question' + qID + ' table.question tbody td' ).click(function (event) {
if ($(this).parents('tr:eq(0)').attr('name') != 'clickedRow') {
addRow();
$(this).parents('tr:eq(0)').attr('name', 'clickedRow');
}
});
// Function to add a row
function addRow() {
$( arrayRow + '[name="hidden"]:first' ).attr('name', 'visible').show();
}
}
// Call the function with a question ID
expandingArray(QQ);
});
</script>