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

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

  • Apr 15, 2019 5:33 AM UTC
  • 3 replies
  • 142 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.
View original

3 replies

WaterSampler
Level 2 ●●
Forum|alt.badge.img+1
  • Level 2 ●●
  • Apr 15, 2019 11:02 AM UTC
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+28
  • QPN Level 5 ●●●●●
  • Answer
  • Apr 15, 2019 11:35 AM UTC
Hi @HPowell, Just remove the code from the function(addOnload) then it should work fine.

  • Apr 15, 2019 3:43 PM UTC
> @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 = ',';} });