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

How to hide the language box based on embedded data?

  • November 14, 2019
  • 4 replies
  • 83 views

Please check the following code for me: if ('${e://Field/Country}'='HKG') { .LanguageSelectorContainer{ display: none; }; }

Best answer by Zhen

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 ! !

4 replies

  • Author
  • November 14, 2019
I have replaced "=" with "==", but still doesn't work

  • Answer
  • November 15, 2019
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 ! !

  • Author
  • November 16, 2019
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?

  • November 16, 2019
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