web2print Posted July 28, 2017 Share Posted July 28, 2017 (edited) 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 July 28, 2017 by web2print Quote Link to comment Share on other sites More sharing options...
step Posted July 28, 2017 Share Posted July 28, 2017 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>'; Quote Link to comment Share on other sites More sharing options...
web2print Posted July 28, 2017 Author Share Posted July 28, 2017 It worked! Thank you for the reply. I appreciate it. Have a great rest of your day! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.