Javascript not working with survey in different languages | XM Community
Skip to main content

I have a survey translated from English to multiple languages. The survey uses some javascript. Now, the javascript does not seem to work when taking the survey in a language different from English. Any idea what’s going on here/how to correct this? Cheers

What is the JavaScript being used for? Is none of it working, or just certain elements?


The javascript is used for a number of tasks. It seems that the one not working relies on some input from a previous question in the survey, that is, I use the following code to get the answer to this previous question:

“var r1ar = "${q://QID1/ChoiceGroup/SelectedAnswers/1}";”

And then to ask a customised question. It works perfectly on the standard survey (in English) but not in the other languages. Not sure whether this is the reason why it might not work here? The remaining JS seems to work fine.

 

 

 


The javascript is used for a number of tasks. It seems that the one not working relies on some input from a previous question in the survey, that is, I use the following code to get the answer to this previous question:

“var r1ar = "${q://QID1/ChoiceGroup/SelectedAnswers/1}";”

And then to ask a customised question. It works perfectly on the standard survey (in English) but not in the other languages. Not sure whether this is the reason why it might not work here? The remaining JS seems to work fine.

 

 

 

Are you able to share more of the code? 


The javascript is used for a number of tasks. It seems that the one not working relies on some input from a previous question in the survey, that is, I use the following code to get the answer to this previous question:

“var r1ar = "${q://QID1/ChoiceGroup/SelectedAnswers/1}";”

And then to ask a customised question. It works perfectly on the standard survey (in English) but not in the other languages. Not sure whether this is the reason why it might not work here? The remaining JS seems to work fine.

 

 

 

Hi @mgr94 ,

I believe the “var r1ar = "${q://QID1/ChoiceGroup/SelectedAnswers/1}";”
this value which you are getting from previous question is Text type(Please confirm).
and if there is any condition you are performing must be based on English only that's why the issue is happening.

As a result, JS is functioning properly when the survey is conducted in English and is compared to English.
However, when a survey is conducted in a different language, the data that comes in as R1AR is translated, and when it is compared to English, the JS logic fails.

for example:

In English survey
good morning=== good morning;        //logic passed

In German survey,
guten morgen=== good morning  //logic failed

 You have to accommodate for translated language or better use recode(numbers) as it will remain same through  out all translated survey (thus less work and headache).

Hope this resolves your query😊!!


Leave a Reply