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

How to Carry Forward all but one?


Forum|alt.badge.img+2

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...

11 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5926 replies
  • September 19, 2024

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();
});

 


Forum|alt.badge.img+2
  • Author
  • Level 2 ●●
  • 7 replies
  • September 19, 2024
TomG wrote:

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.


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5926 replies
  • September 19, 2024
TerryFoster wrote:
TomG wrote:

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.


Forum|alt.badge.img+2
  • Author
  • Level 2 ●●
  • 7 replies
  • September 20, 2024
TomG wrote:
TerryFoster wrote:
TomG wrote:

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.c1[id$=\\~x4]").closest("tr").hide(); });


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5926 replies
  • September 20, 2024
TerryFoster wrote:

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.


Forum|alt.badge.img+2
  • Author
  • Level 2 ●●
  • 7 replies
  • September 20, 2024
TomG wrote:
TerryFoster wrote:

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. 


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5926 replies
  • September 20, 2024

@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.


Forum|alt.badge.img+2
  • Author
  • Level 2 ●●
  • 7 replies
  • September 20, 2024
TomG wrote:

@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.


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5926 replies
  • September 20, 2024
TerryFoster wrote:

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

This should work:

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

 


Forum|alt.badge.img+2
  • Author
  • Level 2 ●●
  • 7 replies
  • September 23, 2024
TomG wrote:
TerryFoster wrote:

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

This should work:

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

 

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


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5926 replies
  • September 24, 2024
TerryFoster wrote:

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+" label[for$=\\~x4]").closest(".slider-container").hide(); 
});

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


Leave a Reply