Forum Discussion

ArchiveUser's avatar
ArchiveUser
Qrew Captain
9 years ago

Can I use a field in an html tag?

I tried this formula in a text formula field, but the background color does not change when I use the text field called Calendar Color in the html tag. I don't get any syntax errors, but the background color doesn't change.  In this example, the Calendar Color field has a value of #0040ff.

"<div style=\"color:white;background-color:[Calendar Color];\"> " &[Calendar Color]& "<div>"

Please let me know if I'm missing something to use a field in an html tag, or if that's just not possible.
  • You were really close - you just needed to put quotes and "&" before and after [Calendar Color], so that the value in the [Calendar Color] field gets filled in.  If [Calendar Color] is inside the quotes, then the string "[Calendar Color]" gets displayed, which is not a valid background-color.

    Here's the updated formula:

    "<div style=\"color:white;background-color:" & [Calendar Color] & ";\"> " &[Calendar Color]& "<div>
    • JanaBaker's avatar
      JanaBaker
      Qrew Cadet
      Awesome!!  One step further....how can you add regular TEXT and a FIELD to this code?  My example:

      IF ([Jury Duty Count Helper] = 0 and [JRY Form] > 0, "<div style=\"color:#D5152E;font-weight:bold; background-color:" &  [Jury Duty Doc Outstanding Duration] & ";\"> " &[Jury Duty Doc Outstanding Duration]& "<div>")

      The text i would want to add would be be "Jury Duty Doc Outstanding for" prior to the field [Jury Duty Doc Outstanding Duration].

      Thanks!