How do I use embedded data in java script to show different background colors in survey Look & Feel? | XM Community
Solved

How do I use embedded data in java script to show different background colors in survey Look & Feel?

  • 21 March 2018
  • 2 replies
  • 11 views

Hello -

I am looking to use embedded data fields in the survey in order to show different color schemes for the survey. Is there a java script that would allow me to say "If embedded data is 'blank1', then show (java script for one color scheme). If embedded data is 'blank2', then (insert java script for second color scheme)."?

I currently have the color scheme java script in place, however, I am looking for the ability to implement these "if, then" scenarios.

Thanks in advance.

-Joseph
icon

Best answer by TomG 22 March 2018, 01:13

View original

2 replies

Userlevel 7
Badge +27
You can pipe embedded data into a JavaScript. For example:
```
var myvar = "${e://Field/myedf}";
```
Just make sure the piped string is always in quotes.
Userlevel 4
Badge +3
And then if `myvar` is blank, you can use something called a coalesce operator `||` as follows:

`const finalVar = myVar || 'alternate value';`

Leave a Reply