Using Javascript and setEmbeddedData to store answer to question containing apostrophe | XM Community
Skip to main content

Hello -
Not sure how to properly do this.
I have a question where one of my dropdown selections contains an apostrophe.
I need to store that answer to an embedded data field using Javascript.
Is there a proper way to do that? Does that need to be encoded, and if so what is the proper way to format that?

e.g., result (location) is:
O’Connor Bldg
Qualtrics.SurveyEngine.setEmbeddedData('LOC', location);
(the above isn't working for me)
Thanks in advance for any suggestions.
Cindy

I think the problem is because you are using the reserved keywork

location
.
See if changing the variable name to something else works.
If it doesn't you can try this code:
Qualtrics.SurveyEngine.addOnReady(function () {
    let ch = Number(this.getSelectedChoices());
    let loc = this.getChoiceContainer().optionstch].innerText;
    Qualtrics.SurveyEngine.setEmbeddedData("LOC", loc);
});
Its applicable to a single answer dropdown.


Leave a Reply