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.
Sign up
Already have an account? Login
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login to the Community
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.

I hope that clarifies my point..