How to make a global variable in Qualtrics | XM Community
Skip to main content
Solved

How to make a global variable in Qualtrics

  • October 14, 2018
  • 4 replies
  • 121 views

Hi, I've made a lot of custom code using javascript across many questions in my Qualtrics survey. Each of the questions uses the same variable and since the variable is an extremely long list of names and for the sake of neatness I want to make a global variable such that custom code in each question will call upon this variable without having to input into each questions custom code section. These questions cannot be combined to a set of multiple form fields. They must all have separate question IDs. Any help will be greatly appreciated!

Best answer by TomG

Add a function to the Look & Feel header that sets and returns the variable. Call the function from the JS in your questions.
View original

4 replies

PeeyushBansal
Level 6 ●●●●●●
Forum|alt.badge.img+39
  • Level 6 ●●●●●●
  • 1144 replies
  • October 14, 2018
You can use custom CSS under look and feel.

  • Author
  • 11 replies
  • October 14, 2018
@bansalpeeyush29 I tried inputting the variable in the custom CSS part, but it didn't seem to work. Do I need to add a <script> tag before and after the variable to make it work? update: I tried adding a <script> tag before and after the variable in the custom css portion and the variable was not recognized in my custom code

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5933 replies
  • Answer
  • October 14, 2018
Add a function to the Look & Feel header that sets and returns the variable. Call the function from the JS in your questions.

  • Author
  • 11 replies
  • October 14, 2018
ah okay I figured out the issue. The list of names had a name with a ' which wouldn't let the code run. Once that was fixed everything worked out

Leave a Reply