Setting a global variable and then call on it at question level | XM Community
Skip to main content
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?
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.
Hi @HPowell,

Just remove the code from the function(addOnload) then it should work fine.
> @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 = ',';}

});

Leave a Reply