Please help us help you and fill where relevant:
Your LimeSurvey version: [Version 3.28.0+220215]
Own server or LimeSurvey hosting: Our Institution hosts the LimeSurvey(c) on its server
Survey theme/template: Fruity
==================
We have just upgraded our LimeSurvey(c) from 2.50 to Version 3.28.0+220215 and my surveys structure and colour have been compromised. Please see attached .Iss file. I am specifically interested in changing the JavaScript for the side-by-side questions and for the question Array (Text) "Please share your education background starting from the most recent degree/qualification" where initially showing only one row and as the user fills the first row, the next one appears, etc. up to three rows. Please see the scripts below.
I have used Tony Partner's JavaScripts which now need editing, I think. I would be most grateful for any help as I do not know JavaScript (just using what has been created by the community so generously). Thank you.
JS for side-by-side questions:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
// Identify the questions
var thisQuestion = $('#question{QID}');
var nextQuestion = $(thisQuestion).nextAll('div[id^="question"]:eq(0)');
var theseQuestions = $(thisQuestion).add(nextQuestion);
// Place the questions side-by side
$(theseQuestions).wrapAll('<div style="width:100%; margin: 0 auto" />');
theseQuestions.css({
'float': 'left',
'width': '50%'
});
$('> table', theseQuestions).css({
'width': '100%'
});
// Some styling for the textareas
$('textarea', theseQuestions).removeAttr('cols').css({
'margin-left': '0',
'margin-right': '0',
'width': '100%'
});
// Equalize heights
if($(thisQuestion).is(':hidden')) {
$(theseQuestions).css({
'position': 'absolute',
'left': '-9999em'
}).show();
equalizeHeights();
$(theseQuestions).css({
'position': 'relative',
'left': 'auto'
}).hide();
}
else {
equalizeHeights();
}
function equalizeHeights() {
var questionTextHeight = 0;
$('td.questiontext', theseQuestions).each(function(i) {
if($(this).height() > questionTextHeight) {
questionTextHeight = $(this).height()
}
$('td.questiontext', theseQuestions).height(questionTextHeight);
});
var answerHeight = 0;
$('td.answer', theseQuestions).each(function(i) {
if($(this).height() > answerHeight) {
answerHeight = $(this).height()
}
$('td.answer', theseQuestions).height(answerHeight);
});
var helpHeight = 0;
$('td.survey-question-help', theseQuestions).each(function(i) {
if($(this).height() > helpHeight) {
helpHeight = $(this).height()
}
$('td.survey-question-help', theseQuestions).height(helpHeight);
});
}
});
</script>
JavaScript for Array (Text):
<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();
// Now, scroll down
}
}
// Call the function with a question ID
expandingArray(37536);
});
</script>
Thank you.
Alex