Jump to content

Changing Color text based on form field rule


web2print

Recommended Posts

Hello,

 

I am having trouble getting text to change between two colors based on the value of a drop down form field. I am a bit of a newbie at Fusionpro but I am slowly learning. I have a document with variable banners that have text on top of the banner. The banner field options switch between black, blue, gray, green, white, and yellow. I want the text to change to white when the user selects the black, blue, gray, green banners and I want it to switch to black when the user selects white or yellow banners. Here is what I currently have:

 

if (Field("Banner") == "Blue" || Field("Banner") == "Black" || Field("Banner") == "Gray" || Field("Banner") == "Green")

{

return '<color name="White">' + Field("Banner Text") + '</color>';

}

else

{

return '<color name="Black">' + Field("Banner Text") + '</color>';

}

 

I have tried this and several other code strings but nothing has worked. I've read some other posts about this same issue but none of it seemed to work. When I upload the template into marcom, the text is all one color (black or white). I was hoping someone here would be able to help me out.

 

Thank you!

Edited by web2print
Link to comment
Share on other sites

When I upload the template into marcom, the text is all one color (black or white)

 

I thought that's was your intention? Your code seems like it should work to me. Does it work locally? Maybe the value of the "Banner" field is "yellow" as opposed to "Yellow?" You could try this:

var color = /yellow|white/i.test(Field("Banner")) ? "Black" : "White";
return '<span color="' + color + '">' + Field("Banner Text") + '</span>';

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...