How to get a text entry in a multiple choice answer using Javascript? | XM Community

How to get a text entry in a multiple choice answer using Javascript?

  • 1 December 2022
  • 7 replies
  • 238 views

Badge +1

Hi there!
I am trying to set as embedded data the text introduced in a text entry that I have allowed in a multiple choice answer.
I need to do it in the same question. Therefore, doing it using the piped text tool is not an option.
Thank you very much
Pablo


7 replies

Userlevel 7
Badge +35

pablobaldor
Do you mind elaborating on your use case more or a visual?

Badge +1

Hi Deepak , of course!
Here's a screenshot of my question:
image.jpeg






I would like to create embedded data that contains the text introduced in the chosen text entry using JavaScript.
It would be similar to the piped text ${q://QIDxxx/ChoiceGroup/SelectedChoicesTextEntry}, although I do not need my embedded data to include the text of the choices without text entry when they are selected. I only care about text entries.
Thank you!
Pablo


Userlevel 7
Badge +35

https://community.qualtrics.com/XMcommunity/discussion/comment/52762#Comment_52762You can do it without javascript if you just need it for the data and not use it on the same page.
Create a branch logic in the survey flow to check if the field is empty or not and then fill in the embedded data.
image.png
The other option could be to force the text entry you can do that by clicking besides the choice text dropdown in survey builder and they would not be able to go ahead without filling it.
image.png
Hope it helps!

Badge +1

https://community.qualtrics.com/XMcommunity/discussion/comment/52763#Comment_52763Hi Deepak,
Thanks for your quick response!
The thing is that I need this embedded data to use it on the same page. That's the problem.
Do you know how can it be done?
Thanks!

Userlevel 7
Badge +35

https://community.qualtrics.com/XMcommunity/discussion/comment/52765#Comment_52765If you need the text on the same page you would have to custom-code it and then embedded data would not be helpful.
You need to create an HTML element id and fill it with the text on the click function.
Hope it helps!

Badge +1

Thanks for your help, Deepak !
This last link is too much for me. I will do it on a separate page, it is not that big of a deal.
However, although it can be done as you showed me above, I still would like to know how to create this embedded data using JS in this question. Can it be done?
Pablo

Userlevel 7
Badge +35

https://community.qualtrics.com/XMcommunity/discussion/comment/52770#Comment_52770You can include something like this in rich content editor>source of where you would like to present the populated text. You can then use this test as Id to fill the html with text.



Leave a Reply