New Survey Taking Experience is Breaking my JavaScript | XM Community
Skip to main content

Hi all,

I like the new look/feel of the New Survey Taking Experience but it’s broken my JavaScript.

I have two pieces of JavaScript: 

  1. To hide a question
  2. To autofill embedded data fields

Can you help?

=====================================

To Hide:

Qualtrics.SurveyEngine.addOnload(function()
{
jQuery("#"+this.questionId).prev('.Separator').hide(); jQuery("#"+this.questionId).hide();
});

=====================================

To Autofill embedded data fields:

Qualtrics.SurveyEngine.addOnload(function()
{
Qualtrics.SurveyEngine.setEmbeddedData( 'caption1', "Tree" );
Qualtrics.SurveyEngine.setEmbeddedData( 'caption2', "Sand" );
Qualtrics.SurveyEngine.setEmbeddedData( 'caption3', "Monkey" );
Qualtrics.SurveyEngine.setEmbeddedData( 'caption4', "Oxygen" );
});

Hi There,

We use this javascript to hide:

Qualtrics.SurveyEngine.addOnload(function()
{
var questionIdToHide = this.questionId;
jQuery("#" + questionIdToHide).css('display', 'none');
});

And this still works to autofill:

Qualtrics.SurveyEngine.addOnReady(function () {
Qualtrics.SurveyEngine.setEmbeddedData('Filter1', 'abcd');
});

Regards,

Romano


Hi There,

We use this javascript to hide:

Qualtrics.SurveyEngine.addOnload(function()
{
var questionIdToHide = this.questionId;
jQuery("#" + questionIdToHide).css('display', 'none');
});

And this still works to autofill:

Qualtrics.SurveyEngine.addOnReady(function () {
Qualtrics.SurveyEngine.setEmbeddedData('Filter1', 'abcd');
});

Regards,

Romano

This works in the “New Survey Taking Experience”? I can’t get it to work :(


@TerryFoster, I see.

Add this javascript within a question.
 

Qualtrics.SurveyEngine.addOnload(function()
{
const el = this.getQuestionContainer();
if (el) el.style.display = 'none';
});
Qualtrics.SurveyEngine.addOnReady(function () {
this.setEmbeddedData('Filter1', 'abcd');
});

 


@TerryFoster, I see.

Add this javascript within a question.
 

Qualtrics.SurveyEngine.addOnload(function()
{
const el = this.getQuestionContainer();
if (el) el.style.display = 'none';
});
Qualtrics.SurveyEngine.addOnReady(function () {
this.setEmbeddedData('Filter1', 'abcd');
});

 

JavaScript to hide works!! Still can’t get the embedded data to work though :(


Hi,

The setEmbeddedData() method is deprecated. You can still use it in old layouts, but not with the new survey taking experience.

You must use setJSEmbeddedData() and prepend your ED fields with __js_ in the survey flow.

See the Question API for more details.


Hi,

The setEmbeddedData() method is deprecated. You can still use it in old layouts, but not with the new survey taking experience.

You must use setJSEmbeddedData() and prepend your ED fields with __js_ in the survey flow.

See the Question API for more details.

I’ve done as instructed but it’s still not working. Can you double check my JavaScript?

=====

Qualtrics.SurveyEngine.addOnload(function ()  {
    setJSEmbeddedData("caption1", "Tree");
    setJSEmbeddedData("caption2", "Sand");
    setJSEmbeddedData("caption3", "Monkey");
    setJSEmbeddedData("caption4", "Oxygen");
})

=====

Embedded data fields are set as “__js_caption1” etc.

 


Hi,

Qualtrics.SurveyEngine.addOnload(function () {
Qualtrics.SurveyEngine.setJSEmbeddedData("caption1", "Tree");
});