I want to be able to add statements dynamically to a Matrix Table using javascript. Can someone please help me accomplish this?
Qualtrics.SurveyEngine.addOnload(function() {
var selectedPark = "${q://QID1/ChoiceGroup/SelectedAnswers/1}";
var selectedRegion = "${e://Field/SelectedRegion}";
var entranceChoices = o];
// 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 = "1997") {
entranceChoices =
{ value: "Entrance A1", text: "Entrance A1" },
{ value: "Entrance A2", text: "Entrance A2" },
{ value: "Entrance A3", text: "Entrance A3" }
];
} else if (selectedPark = "1998") {
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));
element.questionChoices = entranceChoices;
});
I believe the very last part is not working.