Jump to content

Font Color from Field Value Within a Span


rjohns

Recommended Posts

I'd like to change the font color of some text using the value of a field. The field value is the same as the color named defined in FusionPro. Basically, I'm trying to shortcut having to write a couple of lines of code for each color.

 

I've approached it thinking I could write a text rule:

return '<span color=Field("Inside Text Color")>' + Field("Optional Top Message");

 

But it doesn't seem to be picking up the value of the Inside Text Color field. So, I tried this:

 

var textColor = Field("Inside Text Color");
return '<span color=textColor>' + Field("Optional Top Message");

 

But that didn't work either. Any other ideas? Thanks!

Link to comment
Share on other sites

var textColor = Field("Inside Text Color");
return '<span color="' + textColor + '">' + Field("Optional Top Message");

Or just:

return '<span color="' + Field("Inside Text Color")+ '">' + Field("Optional Top Message");

Although, to make sure markup characters in the data are handled correctly:

return '<span color="' + TaggedDataField("Inside Text Color")+ '">' + TaggedDataField("Optional Top Message");

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...