Hi All,
I am setting an embedded data value based on the selected value answer through the following JS on page submit event and update the mailing list accordingly with this value:
Qualtrics.SurveyEngine.addOnPageSubmit(function (type) {
if (type == "next") {
var x = "${e://Field/2nd_wave}";
if (x == ""){
var ans = this.getSelectedChoices();
if ( ans == "1")
{
Qualtrics.SurveyEngine.setEmbeddedData('x', "Yes");
}
else if ( ans == "2")
{
Qualtrics.SurveyEngine.setEmbeddedData('x', "No");
}
else
{
Qualtrics.SurveyEngine.setEmbeddedData('x', "");
}
}
}
});
My question, in above scenario, I am checking if (x == "") means empty. I would like to check also if another question on the same page has a specific answer. For example,
if Q1 (question on the same page) answered Yes and x == "", then apply the if statement otherwise no embedded date is set.
I tried to work with getting the SelectedValue using the pipped text but it seems that Qualtrics does not capture that as the previous question is on the same page.
Your insights and feedback is highly appreciated
Best Regards,
Muqaibil
Inquiry: Setting Embedded Data value based on another question on the same page
Best answer by ahmedA
Please add this JS to the second question, the one with the display logic.
Qualtrics.SurveyEngine.addOnPageSubmit(function () {
const quest = this;
const qc = quest.questionContainer;
document.querySelector("#NextButton").onmouseenter = function () {
if (qc.className.includes("hidden")) {
Qualtrics.SurveyEngine.setEmbeddedData("2nd_wave", "null");
} else {
const choices = quest.getChoices();
const selected = quest.getSelectedChoices();
const value = choices.indexOf(selected[0]) === 0 ? "Yes" : "No";
Qualtrics.SurveyEngine.setEmbeddedData("2nd_wave", value);
}
};
});
Let me know if you face any issues.
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.