Need JavaScript for one question not reading CSS code in survey style sheet | XM Community
Skip to main content
Question

Need JavaScript for one question not reading CSS code in survey style sheet

  • September 17, 2024
  • 2 replies
  • 41 views

KBrady
Level 2 ●●
Forum|alt.badge.img+11
  • Level 2 ●●
  • 37 replies

This is the CSS code I have on the Style Sheet to make all questions where N/A is an option, light gray

 

/*Makes the N/A column light gray on desktop*/
.last {
    background-color: rgba(0,0,0,0.05);
}

 

However I have one question multiple choice question that contains an N/A option but it is not presenting the light gray background as expected.

 

Any thoughts on what Java code I need to add to the question itself?

2 replies

  • Level 4 ●●●●
  • 194 replies
  • October 9, 2024
KBrady wrote:

This is the CSS code I have on the Style Sheet to make all questions where N/A is an option, light gray

 

/*Makes the N/A column light gray on desktop*/
.last {
    background-color: rgba(0,0,0,0.05);
}

 

However I have one question multiple choice question that contains an N/A option but it is not presenting the light gray background as expected.

 

Any thoughts on what Java code I need to add to the question itself?

Check which is the last option. May be N/A is not the last.


Nam Nguyen
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+28
  • QPN Level 8 ●●●●●●●●
  • 1090 replies
  • October 9, 2024

@KBrady You code only work with table type of question (i.e Matrix table, side by side….). With multiple choice it’s gonna be different. Use this Java code to the question instead (i’m assuming N/A option is at the last)

Qualtrics.SurveyEngine.addOnload(function() {

    var questionId = this.questionId;
    var choiceLabels = jQuery("#" + questionId + " .LabelWrapper label");
    choiceLabels.last().css("background-color", "rgba(0, 0, 0, 0.05)");
    var lastChoiceInput = jQuery("#" + questionId + " input[type='radio']").last();
    lastChoiceInput.parent().css("background-color", "rgba(0, 0, 0, 0.05)");
});

Let me know if it work


Leave a Reply