Solved
Get selected answer from dropdown list JS

I have a drop down list of possible values for one of my questions that asks for the respondents CRM vendor. I would like to get the text value of the selected answer from the dropdown list and set it to an embedded variable. My attempt looks like the below:
Qualtrics.SurveyEngine.addOnPageSubmit(function ()
{
var CRM = this.getSelectedAnswers();
Qualtrics.SurveyEngine.setEmbeddedData('CRM' ,CRM);
};
Of course, my code doesn't work and I assuming either my syntax or parameters (maybe both?) are wrong.
Any help is highly appreciated.
Best answer by TomG
> @HPowell said:
> Thanks Tom. Instead of return the number of the choice, is there anyway to have it return the text? i.e. if Salesforce was choice 1 it would assign CRM variable the string of Salesforce and not the value of 1.
```
Qualtrics.SurveyEngine.addOnPageSubmit(function() {
Qualtrics.SurveyEngine.setEmbeddedData("CRM",jQuery("#"+this.questionId+" option:selected").text());
});
```
View originalLeave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.