Forums
This topic is locked
Changing a font color if value = something
Posted 19 Jan 2003 21:52:26
1
has voted
19 Jan 2003 21:52:26 Adam Cronin posted:
Hello <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>Ive searched and searched and still havent found the answer, fingers crossed someone here can help me with this.
I would like the font color of a displayed record to change depending on whether 4 other records contain a certain word.
For example :
rsOverview.Fields.Item("steplabel"

rsOverview.Fields.Item("hz1ccpex"

rsOverview.Fields.Item("hz2ccpex"

rsOverview.Fields.Item("hz3ccpex"

rsOverview.Fields.Item("hz4ccpex"

Then change rsOverview.Fields.Item("steplabel).Value) font color = red.
Did that make sense?! Basically "steplabel" is displayed on this page in green, if hz1ccpex or hz2ccpex or hz3ccpex or hz4ccpex contain the value "certain_word", "steplabel" needs to change to red. If none of the hz*ccpex contain "certain_word" then nothing happens and it stays green.
Ive trawled the posts on conditional statements, one of which gave me an idea but instead of changing the text color it was changing the table cell color. Needless to say I still couldnt work it out!
Many thanks to anyone who can comment/help.
Adam.
Replies
Replied 19 Feb 2003 22:25:05
19 Feb 2003 22:25:05 Ken Dobson replied:
This should get you close to where you want to go. This is based on one field in a database. I had to trim it up, because of several variations of what could be in the field. The variations I was looking for was anything beginning with "Positive".
I put the following above my header code:
<%
Dim Pozitive
%>
<%
Dim trimname
%>
In my dynamic table, I did the following to make the result RED.
<%Pozitive=RS1.Fields.Item "Results"
.Value%>
<%trimname=left(Pozitive, 8)%>
<%If trimname = "Positive" Then%>
<Strong><font color="#FF0000"><%=(RS1.Fields.Item("Results"
.Value)%></font></Strong></td>
<%end if%>
<%If TrimName <> "Positive" Then%>
<%=left((RS1.Fields.Item("Results"
.Value),20)%></td>
<%end if%>
Hope this helps.
I put the following above my header code:
<%
Dim Pozitive
%>
<%
Dim trimname
%>
In my dynamic table, I did the following to make the result RED.
<%Pozitive=RS1.Fields.Item "Results"

<%trimname=left(Pozitive, 8)%>
<%If trimname = "Positive" Then%>
<Strong><font color="#FF0000"><%=(RS1.Fields.Item("Results"

<%end if%>
<%If TrimName <> "Positive" Then%>
<%=left((RS1.Fields.Item("Results"

<%end if%>
Hope this helps.