Please help us help you and fill where relevant:
Your LimeSurvey version: Version 5.6.31
Own server or LimeSurvey hosting: LimeSurvey Cloud
Survey theme/template: own / based on fruity
==================
Hey there,
I'm a a very happy LimeSurvey user and am using it for my company. I have a question regarding javascript. We are offering education and evaluate our courses using limesurvey. The courses are organized in diffent fields which are taught by various teachers and each individual course deals with a specific topic. At the beginning we have a series of dropdown questions that are supposed to be "cascaded". What we wanted to implement, and it's working on android already, is that if you select a field, only the teachers and topics of that field should be displayed in the drop down questions.
As there are changes in our staff and the course topics from time to time we wanted to implement the cascading with javascript. I know it could also be done natively with multiple "paths" through the questionaire, but this would mean to create a LOT of questions each time a change is happening. This is unfeasible using the gui (maybe it could be done quickly by editing the text of the import-export file). Javascript can be changed easily without taking the down the survey and i have already written some helper scripts to make it even easier. However, here's the problem:
The javascript code is working nicely on android devices and computer, but it doesn't work on IOS devices (so far we only tested mobile devices). I have no idea what might be behind this. I thought it's something like javascript disabled by default, but my IOS friends tell me that can you any website without a problem. Do you have any ideas how to fix this?
I'm not a programmer so the problem might be in the code, although I think it's not very complicated. I changed a code snippet by TPartner I found online (therefore the reference). This is what we are using right now (the "code" formatting didn't show a preview, so i used a blockquote instead) inside the "topic" question:
<span style="font-size:18px;">Kursbezeichnung:</span> <script type="text/javascript" data-author="Tony Partner">
$(document).on('ready pjax:scriptcomplete', function() {
var thisQuestion = $('#question{QID}');
var secondContainer = thisQuestion.prevAll('.question-container').eq(1);
// Define the excluded options
var excludes = {
'A1': , // Bau
'A2': , // Elektro
'A3': , // Metall
'A4': , // Sanitär-, Heizung-, Klimatechnik
'A5': , // Holz
'A6': , // Farbe und Gestaltung
'A7': , // Fahrzeuge
'A8': , // Friseur und Kosmetik
'A9': , // Büro und Verwaltung
};
$('.answer-item select', secondContainer).on('change', function(i) {
// Reset the dropdown
$('select.form-control', thisQuestion).val('').trigger('change');
$('select.form-control option', thisQuestion).show();
// Get the value of the previous question
var selectedValue = $(this).val();
// Hide answer options based on selectedValue
$.each(excludes[selectedValue], function(i, val) {
$('select.form-control option', thisQuestion).filter(function() {
return $(this).val() === val;
}).hide();
});
});
});
</script>
As i said I have another script which helps me generate the contents of "excludes".
Why is this not working on IOS devices?? How can I make work? Is there a maintainable alternative approach?
Thank you very much! Limesurvey is fantastic!
David