Get selected answer from dropdown list JSHi I have tried it but It show us nothing in console. How can I see it works true?
Well I have run it before page not submited:
Qualtrics.SurveyEngine.addOnPageSubmit(function () {
var SelectedChoices = jQuery("#"+this.questionId+" option:selected").text()
console.log(SelectedChoices); });Then, I submit page and I wait It show us selected answer in previous submited page. But It shows me nothing.
I guess it doesnt find this.questionId. How can I fix it?
Thanks.
@firat,
The problem isn't with this.questionId. The JS is to get the text from a dropdown, and your question isn't a dropdown.
I've been using the following to extract the text from the webpage itself, maybe it'll work for you as well.
Qualtrics.SurveyEngine.addOnPageSubmit(function (type) {
if (type == "next") {
var selChoice = this.getSelectedChoices();
var choiceRef = "";
var choiceText = "";
for (let i = 0; i < selChoice.length; i++) {
choiceRef = "#" + this.questionId + "-" + selChoice[i] + "-label > span";
choiceText = document.querySelector(choiceRef).innerHTML;
Qualtrics.SurveyEngine.setEmbeddedData(choiceText,true);
}
}
});
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.