How do I get data output from HTML? | XM Community
Solved

How do I get data output from HTML?

  • 24 September 2019
  • 4 replies
  • 59 views

I have added HTML with JavaScript in the HTML view of a descriptive text question. As part of the question two number fields are displayed and have values automatically set when the user moves a circle in the question. I need to store the final values in these two fields as part of my survey data (I am guessing as embedded data). Could anyone help me with how to do this? I am not sure how/where to reference these fields in the JavaScript.

I tried to paste the code I used here but it is too long.
icon

Best answer by KimothiSaurabh 25 September 2019, 16:48

View original

4 replies

Userlevel 4
Badge +18
@KyleFischer - I would suggest to create text entry type question and store value in it rather than storing in embedded data.

If this seems difficult you can set embedded data by javascript as shown below.

Qualtrics.SurveyEngine.addOnPageSubmit(function(type)
{
if(type == "next")
{
Qualtrics.SurveyEngine.setEmbeddedData("embd1", jQuery('#input1').val());
Qualtrics.SurveyEngine.setEmbeddedData("embd2", jQuery('#input2').val());
}
});
Badge +10
I have a Survey question that I am asking for any customers to update their contact information.
This is a text entry question; however I wanted to add a drop down box for the States. I have the HTML code with JavaScript of the Sates. However, I need to know if the data will pull over? Will I need an embedded data javascript as well? Where do I add that in?
Userlevel 4
Badge +18
@MelissaKough17 - Not sure what html and javascript code you have but you can use below code to show list of states as drop down in text box.

Code to put in javascript:-
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
jQuery('input[id*='+this.questionId+']').attr("list","statelist")
});

In question html put the state list as below:-

<datalist id="statelist">
<option value="Alabama">
<option value="Alaska">
<option value="Arizona">
<option value="California">
<option value="Colorado">
</datalist>

This is how it will show list:-

!

There is a drawback of this approach, it will not force respondent to choose from drop down and respondent is free to type in anything because it is text type question. To avoid this you can update javascript and validate typed texts against the list.
Badge +10
@KimothiSaurabh Thank you very much!!!

Leave a Reply