Click to See Complete Forum and Search --> : Red / Green Bgcolor - Scorecard


Chamark
12-28-2006, 09:24 AM
I am attempting to change the background color at the field level to create "at a glance" scorecard. If score is less than goal background should be red, if at or better than goal then background is green. Don't know where to insert (see code)....any help is really appreciated

<tr>
<td><span class="style12"><%=(AllSitesGOALS.Fields.Item("Segment").Value)%></span></td>
<td><span class="style12"><%= FormatPercent((AllSitesGOALS.Fields.Item("Adherence").Value), 2, -2, -2, -2) %></span></td>
<% If (AllSitesGOALS.Fields.Item("Adherence").Value) < (AllSitesGOALS.Fields.Item("Adherence Goal").Value)THEN
Response.Write "<bgcolor = ""Red"" >"
Else
Response.Write "<bgcolor = ""Green"" >"
End IF %>
<td><span class="style12"><%= FormatPercent((AllSitesGOALS.Fields.Item("Adherence Goal").Value), 0, -2, -2, -2) %></span></td>
<td><span class="style12"><%= FormatPercent((AllSitesGOALS.Fields.Item("Adherence Variance").Value), 2, -2, -2, -2) %></span></td>
<td><span class="style12"><%= FormatPercent((AllSitesGOALS.Fields.Item("Efficiency").Value), 2, -2, -2, -2) %></span></td>
<td><span class="style12"><%= FormatPercent((AllSitesGOALS.Fields.Item("Efficiency Goal").Value), 0, -2, -2, -2) %></span></td>
<td><span class="style12"><%= FormatPercent((AllSitesGOALS.Fields.Item("Efficicency Variance").Value), 2, -2, -2, -2) %></span></td>

felgall
12-28-2006, 01:39 PM
1. You can't place any other tags between the </td> ant the following <td> - nothing is allowed there at all.

2. There is no such tag as <bgcolor> - the background colour of elements is defined by the background-color style. The easiest way to do what you are after would be to set up classes with the two colours defined in them and add whichever class you want to the span tags that you already have eg.

<td><span class="style12 <% If (AllSitesGOALS.Fields.Item("Adherence").Value) < (AllSitesGOALS.Fields.Item("Adherence Goal").Value)THEN
Response.Write "Red"
Else
Response.Write "Green"
End IF %>"><%= FormatPercent((AllSitesGOALS.Fields.Item("Adherence Goal").Value), 0, -2, -2, -2) %></span></td>

Chamark
12-28-2006, 04:07 PM
Hey Stephen,

Thanks for your reply. Actually I was able to fit the bgcolor in at the field level like this:
<td bgcolor="#009933"><span class="style12"><%= FormatPercent((AllSitesGOALS.Fields.Item("Adherence").Value), 2, -2, -2, -2) %></span></td>

I just need to know how to add in the if statement as mentioned in my first communication