@MatthewJay , how comfortable are you with Javascript? There is a way to do this but it would require a tad bit of Javascript. Some people might prefer to tackle the conditional formatting route. I also like @MikeW ‘s recommendation to use display logic and piping.
But here is another way to do it. Use Embedded Data to store the selected Park and Region, and then use that information to dynamically populate the matrix question with the corresponding entrances.
Here's how you can do it:
-
Create a new Embedded Data field called "SelectedPark" and another called "SelectedRegion". These fields will be used to store the selected Park and Region values, respectively.
-
In the first question, where the user selects the Region and Park, add some JavaScript to store the selected values in the Embedded Data fields. For example:
Qualtrics.SurveyEngine.addOnload(function() {
var selectedPark = "${q://QID1/SelectedChoices}";
var selectedRegion = "${q://QID2/SelectedChoices}";
Qualtrics.SurveyEngine.setEmbeddedData("SelectedPark", selectedPark);
Qualtrics.SurveyEngine.setEmbeddedData("SelectedRegion", selectedRegion);
});
-
In this example, QID1 is the question where the user selects the Park, and QID2 is the question where the user selects the Region. The JavaScript code retrieves the selected values and stores them in the Embedded Data fields.
-
Create the matrix question where you want to display the entrances. In the question editor, click on the "Advanced Question Options" button and then select "Add JavaScript".
-
In the JavaScript editor, add the following code:
Qualtrics.SurveyEngine.addOnload(function() {
var selectedPark = "${e://Field/SelectedPark}";
var selectedRegion = "${e://Field/SelectedRegion}";
var entranceChoices = [];
// Replace this with your own code to dynamically generate the entrance choices based on the selected Park and Region.
// For example, you could use an API call to retrieve the entrances for the selected Park and Region.
// This example code just hard-codes some sample entrance choices.
if (selectedPark == "Park A" && selectedRegion == "Region 1") {
entranceChoices = [
{ value: "Entrance A1", text: "Entrance A1" },
{ value: "Entrance A2", text: "Entrance A2" },
{ value: "Entrance A3", text: "Entrance A3" }
];
} else if (selectedPark == "Park B" && selectedRegion == "Region 2") {
entranceChoices = [
{ value: "Entrance B1", text: "Entrance B1" },
{ value: "Entrance B2", text: "Entrance B2" }
];
}
// Set the matrix question choices to the dynamically generated entrance choices
Qualtrics.SurveyEngine.setEmbeddedData("EntranceChoices", JSON.stringify(entranceChoices));
this.questionChoices = entranceChoices;
});
This JavaScript code retrieves the values stored in the Embedded Data fields for the selected Park and Region, generates the entrance choices based on those values, and sets the matrix question choices to those dynamically generated entrance choices.
Note that this example code just hard-codes some sample entrance choices for demonstration purposes. You'll need to replace the code with your own code to dynamically generate the entrance choices based on the selected Park and Region.
With this approach, the matrix question will dynamically display the entrance choices based on the selected Park and Region without the need for conditional display logic questions.