How to Carry Forward all but one? | XM Community
Skip to main content

Hello! 

I am asking respondents a total of 4 matrixes. 

In matrix 1 (QID9), there are 5 variables displayed.

In matrix 2 and 3, all 5 variables are carried forward to keep statement randomization order. 

In matrix 4 (QID14), I need to drop the 4th variable as the question doesn’t really apply. However, I’d like to carry forward the other variables and keep randomization order. 

As the point is to keep randomization order, I cannot use “Advanced Randomization” to hide the 4th variable. Is there anything I can do to hide that variable while keeping order? Instinct tells me Javascript...

Your instincts are correct. Use JavaScript to hide the row with the 4th variable (i.e., statement). If you are NOT using Simple layout:

Qualtrics.SurveyEngine.addOnload(function() {
jQuery("#"+this.questionId+" th.c1[id$=\\~4]").closest("tr").hide();
});

 


Your instincts are correct. Use JavaScript to hide the row with the 4th variable (i.e., statement). If you are NOT using Simple layout:

Qualtrics.SurveyEngine.addOnload(function() {
jQuery("#"+this.questionId+" th.c1[id$=\\~4]").closest("tr").hide();
});

 

Hi TomG--I appreciate the reply. Unfortunately, I can’t get it to work. I’m not versed in JavaScript so it is almost definitely user error.


Your instincts are correct. Use JavaScript to hide the row with the 4th variable (i.e., statement). If you are NOT using Simple layout:

Qualtrics.SurveyEngine.addOnload(function() {
jQuery("#"+this.questionId+" th.c1[id$=\\~4]").closest("tr").hide();
});

 

Hi TomG--I appreciate the reply. Unfortunately, I can’t get it to work. I’m not versed in JavaScript so it is almost definitely user error.

That probably means the id of the 4th statement doesn’t end in ~4. Depending on how the question is edited, the numbering doesn’t always start at 1 and may not be sequential. Use the Inspect feature of your browser to determine the id associated with the 4th statement (i.e., variable) then adjust ~4 to the correct number.


Your instincts are correct. Use JavaScript to hide the row with the 4th variable (i.e., statement). If you are NOT using Simple layout:

Qualtrics.SurveyEngine.addOnload(function() {
jQuery("#"+this.questionId+" th.c1[id$=\\~4]").closest("tr").hide();
});

 

Hi TomG--I appreciate the reply. Unfortunately, I can’t get it to work. I’m not versed in JavaScript so it is almost definitely user error.

That probably means the id of the 4th statement doesn’t end in ~4. Depending on how the question is edited, the numbering doesn’t always start at 1 and may not be sequential. Use the Inspect feature of your browser to determine the id associated with the 4th statement (i.e., variable) then adjust ~4 to the correct number.

Heya! After lots of digging into the Inspect tool, I found the screenshot below.

 

Based on the image above, does this JavaScript look correct?

Qualtrics.SurveyEngine.addOnload(function() { jQuery("#"+this.questionId+" th.c1Iid$=\\~x4]").closest("tr").hide(); });


Based on the image above, does this JavaScript look correct?

Qualtrics.SurveyEngine.addOnload(function() { jQuery("#"+this.questionId+" th.c1[id$=\\~x4]").closest("tr").hide(); });

Yes, that looks correct.


Based on the image above, does this JavaScript look correct?

Qualtrics.SurveyEngine.addOnload(function() { jQuery("#"+this.questionId+" th.c1[id$=\\~x4]").closest("tr").hide(); });

Yes, that looks correct.

Bummer, for some reason it isn’t working. Thanks for trying. I’ll search for a different solution. 


@TerryFoster - I see the problem, you are using Simple layout.  In my initial response, I said if you are NOT using Simple layout. I’m not sure what type of matrix you have; it doesn’t look like a Likert. Since I don’t know, I’m guessing, but you can try changing closest("tr") to closest(".statement-container"). However, you may need to go further up the tree than what is shown in your screenshot.


@TerryFoster - I see the problem, you are using Simple layout.  In my initial response, I said if you are NOT using Simple layout. I’m not sure what type of matrix you have; it doesn’t look like a Likert. Since I don’t know, I’m guessing, but you can try changing closest("tr") to closest(".statement-container"). However, you may need to go further up the tree than what is shown in your screenshot.

Sorry--I’m using slider scales for these matrixes.


Sorry--I’m using slider scales for these matrixes.

This should work:

Qualtrics.SurveyEngine.addOnload(function() {
this.getQuestionContainer().querySelector(".slider-statementnid$=-x4]").style.display = "none";
});

 


Sorry--I’m using slider scales for these matrixes.

This should work:

Qualtrics.SurveyEngine.addOnload(function() {
this.getQuestionContainer().querySelector(".slider-statementnid$=-x4]").style.display = "none";
});

 

Ugh, for some reason, it isn’t 😞. Should I be copying/pasting the code as written by you?


Ugh, for some reason, it isn’t 😞. Should I be copying/pasting the code as written by you?

Yes, the code as written worked for me for in me Simple layout on a Slider question with carryforward. So, I think you are using a different layout. Try:

Qualtrics.SurveyEngine.addOnload(function() {
jQuery("#"+this.questionId+" labelbfor$=\\~x4]").closest(".slider-container").hide();
});

For future questions, you should include the layout type and question type at the start.


Leave a Reply