For the benefit of others, you are trying to save the order of sub-questions of a first array in a hidden short-text question. Then, in a later group, you retrieve that order and use it to manipulate the order of a second array.
It looks like the scripts you are using are for multiple-choice type questions.
For arrays, this should be the script in the first question:
Code:
<script type="text/javascript" data-author="Tony Partner">
$(document).on('ready pjax:scriptcomplete',function(){
//Identify the questions
var thisQuestion = $('#question{QID}');
var hiddenQuestion = $(thisQuestion).nextAll('.text-short:eq(0)');
// Create an array of answer codes
var answerCodes = [];
$('tr.answers-list', thisQuestion).each(function(i) {
answerCodes.push($(this).attr('id').split('X{QID}')[1]);
});
// Load the hidden question
$('input:text', hiddenQuestion).val(answerCodes);
});
</script>
This should be in the second question:
Code:
<script type="text/javascript" data-author="Tony Partner">
$(document).on('ready pjax:scriptcomplete',function(){
//Identify this question
var thisQuestion = $('#question{QID}');
var thisAnswerList = $('tr.answers-list:eq(0)', thisQuestion).parent();
// Retrieve the answer codes from the "randomOrder2" question
var answerCodes = '{randomOrder2}'.split(',');
// Loop through the answer codes
$.each(answerCodes, function(i, val) {
// Move the answer item
$(thisAnswerList).append($('tr.answers-list[id$="X{QID}'+val+'"]', thisQuestion));
});
});
</script>
Sample survey attached:
Another issue - LS 6.x uses Bootstrap 5 so, when hiding a question via a CSS class, use "d-none" instead of "hidden".