Hi, I’m trying to create a text entry question called Risk Rating that will calculate one’s eligibility based on their answers to prior questions in the survey. I’ve written this Java Script but nothing seems to appear in the actual text entry box for Risk Rating when I preview the survey. If anyone has any assistance or recommendations that would be greatly appreciated. Thanks!
Qualtrics.SurveyEngine.addOnload(function() {
// Function to check eligibility based on the answers
function checkEligibility() {
var suspendedAnswer = "${q://QID4/ChoiceGroup/SelectedChoices}";
var delinquentAnswer = "${q://QID5/ChoiceGroup/SelectedChoices}";
var singleAuditAnswer = "${q://QID6/ChoiceGroup/SelectedChoices}";
var ueAnswer = "${q://QID7/ChoiceGroup/SelectedChoices}";
if (suspendedAnswer === "No" ||
delinquentAnswer === "No" ||
singleAuditAnswer === "No" ||
ueAnswer === "No") {
// Set the eligibility to "Ineligible"
Qualtrics.SurveyEngine.setEmbeddedData("Eligibility", "Ineligible");
} else {
// Set the eligibility to "Eligible"
Qualtrics.SurveyEngine.setEmbeddedData("Eligibility", "Eligible");
}
}
// Add event listeners to check for changes in the question answers
var questionIds = n"QID4", "QID5", "QID6", "QID7"];
for (var i = 0; i < questionIds.length; i++) {
var qID = questionIdsi];
this.questionclick = checkEligibility;
}
// Initial check
checkEligibility();
});