mardi 4 juin 2019

How to access LimeSurvey user input via JavaScript DropDown mask using ifelse-statement?

I created a matrix question in limesurvey. Using html-code i access a javascript with predefined variables and functions that provide dropdown menus displayed as an overlay on the predefined matrix. I want to assess education paths with my question. When a person gives a certain response, e.g. A in the first dropdown field, the second dropdown field shall be filled with a different dropdown format than when a person enters for example B. Dropdown answers are stored in variables (see code). I inserted an ifelse-statement but unfortunately it does not work.

I already tried to access the response options (that are stored in different variables) by using logical operators relating to predefined numerical values as well as strings.

var questionLayout;       // creating the dropdown overlay

function initQuestionLayout() {
questionLayout = [
    getEducationTypesDropdown, // Art der Ausbildung
    getDatePickerDropdownFrom, // von
    getDatePickerDropdownTo, // bis
    getEducationAreasDropdown, // Bereich der Ausbildung
    getEducationDegreesDropdown, // Abschluss (abgeschlossen,...)
];
}


var educationTypes = [                  // example variable definition
    {val : '', text: ''},
    {val : 1, text: 'Berufsausbildung'},
    {val : 2, text: 'duales Studium'},
    {val : 3, text: 'Studium Bachelor (Universität)'},
    {val : 4, text: 'Studium Bachelor (Fachhochschule)'},
    {val : 5, text: 'Studium Master (Universität)'},
    {val : 6, text: 'Studium Master (Fachhochschule)'},
    {val : 7, text: 'Studium Staatsexamen'},
    {val : 8, text: 'Studium Diplom'},
    {val : 9, text: 'im Übergangssystem (z.B. Orientierungsstudium)'},
    {val : 10, text: 'Fort- oder Weiterbildung'},
    {val : 11, text: 'Andere Ausbildung oder Studium'},

function ifelsefuction() {            // ifelse statement
var test = educationTypes.text;
if(test=='Berufsausbildung'){
return getSelectBox(areas, true);       
}
else{
return getSelectBox(yesno, true);       
}
}

Aucun commentaire:

Enregistrer un commentaire