Skip to content

Instantly share code, notes, and snippets.

@berteh
Created August 7, 2013 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save berteh/6172577 to your computer and use it in GitHub Desktop.
Save berteh/6172577 to your computer and use it in GitHub Desktop.
Merge multidimensional arrays of 2 different questions in LimeSurvey 2.00+
// merges inputs of multidimensional arrays of 2 different question (same group/page) in Limesurvey. The lines must be similar.
function mergeTables(q1id, q2id, textBoxSize = 20) {
//hide second text
$('#'+q2id+' .survey-question-text').hide();
//merge tables
var t1 = $('#'+q1id+' .survey-question-answer table');
var t2 = $('#'+q2id+' .survey-question-answer table');
//move titles
$('thead tr', t1).append($('thead tr th', t2));
$('thead', t2).remove();
//move inputs
$('tbody tr', t1).each(function( index ) {
$(this).append($('tbody tr:first-of-type td', t2)) ;
$('tbody tr:first-of-type', t2).remove();
});
//clean table 2
t2.remove();
// (option) resize text inputs
$('input[type="text"]',t1).attr('size',textBoxSize);
}
$(document).ready(function(){
mergeTables('question16611','question16613', 10);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment