-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added function for complex display logic
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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(); | ||
} | ||
}); |