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

How to make a global variable in Qualtrics

  • 14 October 2018
  • 4 replies
  • 28 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!
icon

Best answer by TomG 14 October 2018, 11:37

View original

4 replies

Userlevel 7
Badge +33
You can use custom CSS under look and feel.
@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
Userlevel 7
Badge +27
Add a function to the Look & Feel header that sets and returns the variable. Call the function from the JS in your questions.
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