Using HTML with Multiple Conditions in Text Field

  • 0
  • 1
  • Question
  • Updated 3 years ago
  • Answered
I'm trying to add HTML to a formula that has multiple conditions, but I keep returning syntax errors. The formula I am using is below:
If(
[Total Score]>”38", “span style=\"color:green; font-weight:bold\”>Great</span>”,
[Total Score]>”22", “span style=\"color:yellow; font-weight:bold\”>Average</span>”,[Total Score]>”9", “span style=\”color:red; font-weight:bold\”>Poor</span>”)

The error message comes, I believe, because of the conditions' use of > but I don't know if there is a work-around option. The formula works just fine without the HTML, but I would like to be able to format the output text somehow. Thanks!
Photo of Tithi

Tithi

  • 0 Points

Posted 3 years ago

  • 0
  • 1
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 67,348 Points 50k badge 2x thumb
Is the field type for [Total Score] numeric?  If so, then you do not use "38", just 38.
Photo of Tithi

Tithi

  • 0 Points
The problem persists even without the quotation marks around the numbers. [Total Score] is numeric, yes.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 67,348 Points 50k badge 2x thumb
There is some help examples here of how to color the background of a field.
http://www.quickbase.com/user-assistance/Default.html#color_field.html
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,074 Points 20k badge 2x thumb
Try this;

If(
  [Total Score] > 38, "<span style='color:green; font-weight:bold'>Great</span>",
  [Total Score] > 22, "<span style='color:yellow; font-weight:bold'>Average</span>",
  [Total Score] >  9, "<span style='color:red; font-weight:bold'>Poor</span>"
)

You were missing the opening angle bracket (ie "<") on your span tags. 

Note you don't have to escape double quotes if you use single quotes when defining the style attributes.

I think you will find that yellow text does not show up well against a white background.