How to hide the language box based on embedded data? | XM Community
Solved

How to hide the language box based on embedded data?

  • 14 November 2019
  • 4 replies
  • 45 views

Please check the following code for me:

if ('${e://Field/Country}'='HKG') {
.LanguageSelectorContainer{
display: none;
};
}
icon

Best answer by Zhen 15 November 2019, 06:02

View original

4 replies

No problem xiangyu, great it works for you!

It can be added to each question as inline JS as you've suggested; or extract it out to a separate external JS file and embed it to survey header/footer via "Looks and Feel".

Cheers,
Zhen
Hi @Zhen ,
Thanks a lot for your help. It works now.
Just to confirm, if I want to hide the language box for the entire survey if country==HKG, then I need to add the JavaScript into each Question of the survey?
Hi @xiangyu

You're in the right direction. But you've mixed JavaScript with CSS. It could be done in like this:

Edit Question JavaScript
```
if ('${e://Field/Country}'=='HKG') {
jQuery('.LanguageSelectorContainer').addClass('LanguageSelectorContainerHK');
}
```

Paste CSS into "Look and Feel" -> "General" -> "Style" -> "Custom CSS"
```
.LanguageSelectorContainerHK {
display: none;
};
```

Just make sure you've added "LanguageSelectorContainer" class name to the question html.

Hope it helps, cheers.
Zhen


!

!
I have replaced "=" with "==", but still doesn't work

Leave a Reply