Created
August 7, 2013 09:29
-
-
Save berteh/6172577 to your computer and use it in GitHub Desktop.
Merge multidimensional arrays of 2 different questions in LimeSurvey 2.00+
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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