-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathComplex Display Logic.js
34 lines (28 loc) · 1.05 KB
/
Complex Display Logic.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Qualtrics.SurveyEngine.addOnload(function () {
// Hide the question as soon as the page loads
this.getQuestionContainer().hide();
//Variable to decide whether to show the question or not. Initially false
show_answer = false;
//Create an embedded variable with all the valid choices using a seperator
// In this a comma "," is used
var valid_choices = "${e://Field/valid_choices}";
valid_choices = valid_choices.split(",");
//Get your entered choice. This is showning an embedded variable
// Which you can set based on your question type.
const entered_choice = "${e://Field/entered_choice}";
// Check if the entered choice is equal to any of the valid choices
valid_choices.forEach((item) => {
if (item.trim() == entered_choice) {
show_answer = true;
}
});
//Show the question, if the condition is met
if (show_answer == true) {
this.getQuestionContainer().show();
}
//Optionally you can add a condition to click the next button
// If you only have that one question on the page
if (show_answer == false) {
this.clickNextButton();
}
});