Set Text Box response from embedded data | XM Community
Skip to main content

I want to pull a query string from the URL and use the value as the default value for a text question.  The value is coming from an internal site.

I have created and set an embedded data element (working fine) but cannot get the value to show in the response text box.

I tried a few things after setting GRP_ID variable to the embedded data:

      jQuery(this).val(GRP_ID) ;

      jQuery("#QR\\~"+this.questionId).val(GRP_ID) ;

     questionId.setCodeValue(1,GRP_ID) ;

 

What is the proper syntax to refer to and set the text box value?

You don’t need JavaScript to do this.  In your text entry question click ‘Default choices’ then pick  Embedded Data Field → GRP_ID.


That works great! 

However, if I wanted to do some transformation on the embedded data before setting the value, I could generate the final value with javascript and then how would I set this calculated value as the default value?


That works great! 

However, if I wanted to do some transformation on the embedded data before setting the value, I could generate the final value with javascript and then how would I set this calculated value as the default value?

Like this:

Qualtrics.SurveyEngine.addOnload(function() {
var mystring = "string value";
jQuery("#"+this.questionId+" .InputText").val(mystring);
});

 


You can also try writing it as,

jQuery(this).input(type=”text”).val(Qualtrics.getEmbeddedData(‘GRP_ID’))


Leave a Reply