The RGB function is used to style text with a specific color by using it nested inside a function call to TextColor. It cannot be used to produce a specific fill color.
Here is a sample I created that uses the webviewer to display a color swatch. This sample uses two custom functions to convert decimals to hexadecimals and both functions were obtained from www.brianDunning.com
You could use a Web Viewer, as Chamblee said.
But I do not see why you'll need a Custom Function because you could simply set it to:
<body margin='0' style=border:'0' bgcolor=rgb(" &
& "," &
& "," &
where red, green and blue are the names of your 3 fields.
Thanks everyone for helping this strictly paste & pray coder!
raybaudi's no-custom-function solution worked fine as soon as I figured what I needed to replace "YourTable" with :/
Tried Chamblee's custom function route as well, but could not get this to work.
- Copied both custom functions, HTML code & created the calculated field Hex.
- Plugged in my RGB field names & my file name directory for container.
- Result: Hex field didn't get any values.
Would like to understand why this didn't work...might need to use a custom function someday.
You need advance to create custom functions. File, Manage, Custom functions. You can import the function from the sample into your own databases, and you also can copy the hex calculation field from the sample database. You don't have to use a custom function. Three are many way to do things. The contact starter solution uses custom functions for the google maps, but it can be done without. I was making a sample to show how it could be done.
I posted a similar problem and an answer led me to this. This is awesome! I have been trying to make this happen for a while, but do not know any HTML, so this is a great start. But I am having trouble with making this do exactly what I need it to. There is just one problem, and it's kind of weird.
In my use for this, I need for the 3 fields when at full (FF or 255) are black, and when out (00 or 0) are white, so that when red is at full it is full on red in the viewer and so on and so forth. At the moment, for whatever reason, the colors are completely off. For instance, when the red is at 255 it's a very dark green, and for whatever reason when all 3 are at 00 or FF instead of 0 or 255 the viewer goes red. I've double checked the code to make sure that the red green and blue fields are correctly placed according to your code. Is there any way to fix this?
And one more question, is it all possible to make the color extend to the edge of the web viewer without making the fill "none" so that the color itself can have curved corners?
any and all help is much appreciated! Thank you!
Update: I got it working to give the correct colors, but I am stuck on making it on a subtractive color wheel within the web viewer. Also, the information I have is in a percentage form on an excel document. Is there any way to convert the percentage into the HTML color code?
To Chamblee: Finally got you solution working as well. It's useful to know several approaches.
My mistake was to define the Hex field type as "text" and paste the calculation into the field options.
Once I changed the Hex field type to "calculation", the RGB values were passed along.
The Web Viewer works whether the Hex field calculation result is set to either number or text.
Thanks again so much!
I figured it out as well! It was actually really easy, just a second red/green/blue field that multiplied the decimal to an RGBdecimal which was then used in Chamblee's custom function to be put into HexDecimal format. Using that I can now have an archive of all the colors from different gel manufacturers and change the color of a web view based on the value of a field that pulls from that archive.
Both methods worked for the web viewer, by the way. I liked working with custom functions a little.
Thank you! This was an amazing help!