How do I use embedded data in java script to show different background colors in survey Look & Feel? | XM Community
Skip to main content
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
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.
And then if `myvar` is blank, you can use something called a coalesce operator `||` as follows:



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

Leave a Reply