Setting a global variable and then call on it at question level | XM Community
Skip to main content
Solved

Setting a global variable and then call on it at question level

  • April 15, 2019
  • 3 replies
  • 111 views

Forum|alt.badge.img+1
I want to set a global variable in the header based on the language that is selected and then be able to call on it at the question level. My attempt is below, but I cannot seem to get it to work. <script> Qualtrics.SurveyEngine.addOnload(function() { if (jQuery('#Q_lang').val() == 'DE' || jQuery('#Q_lang').val() == 'NL'){var delimeter = '.';} else {var delimeter = ',';} }); </script> Any suggestions?

Best answer by NiC

Hi @HPowell, Just remove the code from the function(addOnload) then it should work fine.

3 replies

WaterSampler
Level 2 ●●
Forum|alt.badge.img+1
  • Level 2 ●●
  • April 15, 2019
Have you tried using embedded data as the way to store the delimiter? Create the embedded data in survey flow at the start of the survey and set it from your javascript.

NiC
QPN Level 5 ●●●●●
Forum|alt.badge.img+27
  • QPN Level 5 ●●●●●
  • Answer
  • April 15, 2019
Hi @HPowell, Just remove the code from the function(addOnload) then it should work fine.

  • April 15, 2019
> @NiC said: > Hi @HPowell, > Just remove the code from the function(addOnload) then it should work fine. Agreed with @NiC , Just paste the below code in the first question of your survey which will be definitely be displayed to all respondent, outside all the function. if (jQuery('#Q_lang').val() == 'DE' || jQuery('#Q_lang').val() == 'NL'){var delimeter = '.';} else {var delimeter = ',';} });