Hi Tony - 3 years later, and we have a repeat of the same event happening, so I am using the same code that I used in 2016, but with a new version of Lime Survey - I'm now using 3.17.9+... and this code is not working. I've set "Filter HTML for XSS" to "Off" and used the exact same survey that I used in 2016, but none of the rank options show in this version. Any suggestions on how to make it work?
This is a sample of the code I'm using, this is for question "arHidden", then the following question (Active Rec) is a ranking question with an array filter of arHidden:
Code:
A hidden question to control the ranking. <script type="text/javascript" charset="utf-8">
$(document).ready(function() {
// Identify the questions
var arHidden = $('#question{QID}');
var arHiddenID = $(arHidden).attr('id').replace(/question/, '');
// Hide the checkbox question
arHidden.css({
'position': 'absolute',
'left': '-9999em'
});
// The ranking answer codes relevant for the various values of "Branch"
// EDIT HERE AS REQUIRED
var answerCodes = {
1: ['101', '102', '103', '104', '105', '106', '107', '108', '109', '110', '111', '112', '113', '114', '115'], // Seen by "Rangers"
2: ['101', '102', '103', '104', '105', '106', '107', '108', '109', '110', '111', '112', '113', '114', '115'], // Seen by "Pathfinders"
3: ['101', '103', '104', '105', '106', '108', '109', '110', '112', '114', '115'] // Seen by everybody else
}
// Get the value of the "Branch" question
var branch = '{Branch}';
console.log(branch);
// Define which set of ranking answer codes to display
if(branch == 'Ranger') {
var codeArray = answerCodes[1];
}
else if(branch == 'Pathfinder') {
var codeArray = answerCodes[2];
}
else {
var codeArray = answerCodes[3];
}
// Toggle the appropriate checkboxes and fire Expression Manager
$('input.checkbox[id$="X'+arHiddenID+this+'"]').prop('checked', false);
$('.question-item input:hidden', arHidden).val('');
$(codeArray).each(function(i) {
var thisInput = $('input.checkbox[id$="X'+arHiddenID+this+'"]');
thisInput.prop('checked', true);
thisInput.nextAll('input:hidden').val('Y');
checkconditions(thisInput.value, thisInput.name, thisInput.type)
});
});
</script>