Solved

Changing Text color based on value of query

Posted on 2004-04-27
7
271 Views
Last Modified: 2013-12-24
I would like to have my results page display the value of the "status" column
with the color of the value.

Example: "status" can be red. yellow or green.
If the "status" is yellow I would like it to display the yellow value in bold yellow text.
0
Comment
Question by:tmurray22
  • 4
  • 2
7 Comments
 
LVL 7

Expert Comment

by:MaB
ID: 10929469
Hi tmurray22,
Do you have a reference page or source to post?

Basicly you can use CSS to accomodate this.
You could name the column with an id, for example id="status", and then apply the style to that elment.

document.getElementById("status").style.color = status

using status as a variable containing any of the colors.

It would be easier to describe and try to solve if you present the code here.

BR MaB!
0
 
LVL 12

Expert Comment

by:rcmb
ID: 10929541
In your database results display page switch to html view and find

<!--#include file="_fpclass/fpdbrgn1.inc"-->
<!--webbot bot="DatabaseRegionStart" endspan i-checksum="56121" -->

Immediately after this code enter

<%
varStatus = fp_rs("Status")
If varStatus = "red" OR varStatus = "Red" Then
    varFontColor = "FF0000"
    varBstart = "<b>"
    varBend = "</b>"
Elseif varStatus = "yellow" OR varStatus = "Yellow" Then
    varFontColor = "FFFF00"
    varBstart = "<b>"
    varBend = "</b>"
Elseif varStatus = "green" OR varStatus = "Green" Then
    varFontColor = "00FF00"
    varBstart = "<b>"
    varBend = "</b>"
Else
   varFontColor = ""
    varBstart = ""
    varBend = ""
End if
%>

In the line where you display you results you will find something like:

<!--webbot bot="DatabaseResultColumn" s-columnnames="ID,Name,Modified,CDDVDClientJob" s-column="Name" b-tableformat="TRUE" b-hashtml="FALSE" b-makelink="FALSE" clientside b-MenuFormat preview="&lt;font size=&quot;-1&quot;&gt;&amp;lt;&amp;lt;&lt;/font&gt;Name&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"Name")%><!--webbot bot="DatabaseResultColumn" endspan i-CheckSum="3900" -->

This is the webbot results for displaying your field information

bracket this information with
<font color="<%=varFontColor%>"><%=varBstart%>........<%=varBend%></font>

RCMB

0
 

Author Comment

by:tmurray22
ID: 10933275
RCMB

It isn't working, Not sure I Bracketed the information you supplied correctly. I'm not getting any errors just not the color change.


Here is my code

<html>

<head>
<% ' FP_ASP -- ASP Automatically generated by a Frontpage Component. Do not Edit.
FP_CharSet = "windows-1252"
FP_CodePage = 1252 %>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>SystemRelease</title>
</head>

<body>

<p align="center"><img border="0" src="susheader.jpg" width="614" height="111"></p>
<table width="100%" border="1">
  <thead>
    <tr>
      <th ALIGN="LEFT">UPDATE</th>
      <th ALIGN="LEFT"><b>SystemRelease</b></th>
      <th ALIGN="LEFT"><b>BuildStatus</b></th>
      <th ALIGN="LEFT"><b>GatingPtrs</b></th>
      <th ALIGN="LEFT"><b>CurrentBuildNum</b></th>
      <th ALIGN="LEFT"><b>NextBuildNum</b></th>
      <th ALIGN="LEFT"><b>PreviousGABuild</b></th>
      <th ALIGN="LEFT"><b>Comments</b></th>
    </tr>
  </thead>
  <tbody>
    <!--webbot bot="DatabaseRegionStart" s-columnnames="ReleaseID,SystemRelease,BuildStatus,GatingPtrs,CurrentBuildNum,NextBuildNum,PreviousGABuild,Comments" s-columntypes="3,202,202,202,202,202,202,202" s-dataconnection="Database6" b-tableformat="TRUE" b-menuformat="FALSE" s-menuchoice s-menuvalue b-tableborder="TRUE" b-tableexpand="TRUE" b-tableheader="TRUE" b-listlabels="TRUE" b-listseparator="TRUE" i-listformat="0" b-makeform="FALSE" s-recordsource="SUtable" s-displaycolumns="ReleaseID,SystemRelease,BuildStatus,GatingPtrs,CurrentBuildNum,NextBuildNum,PreviousGABuild,Comments" s-criteria s-order s-sql="SELECT * FROM SUtable" b-procedure="FALSE" clientside suggestedext="asp" s-defaultfields s-norecordsfound="No records returned." i-maxrecords="256" i-groupsize="0" botid="0" u-dblib="_fpclass/fpdblib.inc" u-dbrgn1="_fpclass/fpdbrgn1.inc" u-dbrgn2="_fpclass/fpdbrgn2.inc" tag="TBODY" preview="&lt;tr&gt;&lt;td colspan=64 bgcolor=&quot;#FFFF00&quot; width=&quot;100%&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;This is the start of a Database Results region.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;" startspan --><!--#include file="_fpclass/fpdblib.inc"-->
<% if 0 then %>
<SCRIPT Language="JavaScript">
document.write("<div style='background: yellow; color: black;'>The Database Results component on this page is unable to display database content. The page must have a filename ending in '.asp', and the web must be hosted on a server that supports Active Server Pages.</div>");
</SCRIPT>
<% end if %>
<%
fp_sQry="SELECT * FROM SUtable"
fp_sDefault=""
fp_sNoRecords="<tr><td colspan=8 align=""LEFT"" width=""100%"">No records returned.</td></tr>"
fp_sDataConn="Database6"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_sColTypes="&ReleaseID=3&SystemRelease=202&BuildStatus=202&GatingPtrs=202&CurrentBuildNum=202&NextBuildNum=202&PreviousGABuild=202&Comments=202&"
fp_iDisplayCols=8
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="_fpclass/fpdbrgn1.inc"-->
<!--webbot bot="DatabaseRegionStart" endspan i-checksum="13228" --><tr>
<%
varStatus = fp_rs("BuildStatus")
If varStatus = "red" OR varStatus = "Red" Then
    varFontColor = "FF0000"
    varBstart = "<b>"
    varBend = "</b>"
Elseif varStatus = "yellow" OR varStatus = "Yellow" Then
    varFontColor = "FFFF00"
    varBstart = "<b>"
    varBend = "</b>"
Elseif varStatus = "green" OR varStatus = "Green" Then
    varFontColor = "00FF00"
    varBstart = "<b>"
    varBend = "</b>"
Else
   varFontColor = ""
    varBstart = ""
    varBend = ""
End if
%>

      <td>
      <p align="center">
      <a href="suedit.asp?ReleaseID=<%=FP_FieldURL(fp_rs,"ReleaseID")%>">Edit</a></td>
      <td>
      <font color=<%=varFontColor%>"><%=varBstart%></font><!--webbot bot="DatabaseResultColumn" s-columnnames="ReleaseID,SystemRelease,BuildStatus,GatingPtrs,CurrentBuildNum,NextBuildNum,PreviousGABuild,Comments" s-column="SystemRelease" b-tableformat="TRUE" b-hashtml="FALSE" b-makelink="FALSE" clientside b-MenuFormat preview="&lt;font size=&quot;-1&quot;&gt;&amp;lt;&amp;lt;&lt;/font&gt;SystemRelease&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"SystemRelease")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="36759" --></td>
      <td>
      <!--webbot bot="DatabaseResultColumn" s-columnnames="ReleaseID,SystemRelease,BuildStatus,GatingPtrs,CurrentBuildNum,NextBuildNum,PreviousGABuild,Comments" s-column="BuildStatus" b-tableformat="TRUE" b-hashtml="FALSE" b-makelink="FALSE" clientside b-MenuFormat preview="&lt;font size=&quot;-1&quot;&gt;&amp;lt;&amp;lt;&lt;/font&gt;BuildStatus&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"BuildStatus")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="32721" --></font></p>
      </td>
      <td>
      <!--webbot bot="DatabaseResultColumn" s-columnnames="ReleaseID,SystemRelease,BuildStatus,GatingPtrs,CurrentBuildNum,NextBuildNum,PreviousGABuild,Comments" s-column="GatingPtrs" b-tableformat="TRUE" b-hashtml="FALSE" b-makelink="FALSE" clientside b-MenuFormat preview="&lt;font size=&quot;-1&quot;&gt;&amp;lt;&amp;lt;&lt;/font&gt;GatingPtrs&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"GatingPtrs")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="29459" --></td>
      <td>
      <!--webbot bot="DatabaseResultColumn" s-columnnames="ReleaseID,SystemRelease,BuildStatus,GatingPtrs,CurrentBuildNum,NextBuildNum,PreviousGABuild,Comments" s-column="CurrentBuildNum" b-tableformat="TRUE" b-hashtml="FALSE" b-makelink="FALSE" clientside b-MenuFormat preview="&lt;font size=&quot;-1&quot;&gt;&amp;lt;&amp;lt;&lt;/font&gt;CurrentBuildNum&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"CurrentBuildNum")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="40737" --></td>
      <td>
      <!--webbot bot="DatabaseResultColumn" s-columnnames="ReleaseID,SystemRelease,BuildStatus,GatingPtrs,CurrentBuildNum,NextBuildNum,PreviousGABuild,Comments" s-column="NextBuildNum" b-tableformat="TRUE" b-hashtml="FALSE" b-makelink="FALSE" clientside b-MenuFormat preview="&lt;font size=&quot;-1&quot;&gt;&amp;lt;&amp;lt;&lt;/font&gt;NextBuildNum&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"NextBuildNum")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="27508" --></td>
      <td>
      <!--webbot bot="DatabaseResultColumn" s-columnnames="ReleaseID,SystemRelease,BuildStatus,GatingPtrs,CurrentBuildNum,NextBuildNum,PreviousGABuild,Comments" s-column="PreviousGABuild" b-tableformat="TRUE" b-hashtml="FALSE" b-makelink="FALSE" clientside b-MenuFormat preview="&lt;font size=&quot;-1&quot;&gt;&amp;lt;&amp;lt;&lt;/font&gt;PreviousGABuild&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"PreviousGABuild")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="34608" --></td>
      <td>
      <!--webbot bot="DatabaseResultColumn" s-columnnames="ReleaseID,SystemRelease,BuildStatus,GatingPtrs,CurrentBuildNum,NextBuildNum,PreviousGABuild,Comments" s-column="Comments" b-tableformat="TRUE" b-hashtml="FALSE" b-makelink="FALSE" clientside b-MenuFormat preview="&lt;font size=&quot;-1&quot;&gt;&amp;lt;&amp;lt;&lt;/font&gt;Comments&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"Comments")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="16369" --></td>
    </tr>
    <!--webbot bot="DatabaseRegionEnd" b-tableformat="TRUE" b-menuformat="FALSE" u-dbrgn2="_fpclass/fpdbrgn2.inc" i-groupsize="0" clientside tag="TBODY" preview="&lt;tr&gt;&lt;td colspan=64 bgcolor=&quot;#FFFF00&quot; width=&quot;100%&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;This is the end of a Database Results region.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;" startspan --><!--#include file="_fpclass/fpdbrgn2.inc"-->
<!--webbot bot="DatabaseRegionEnd" endspan i-checksum="62730" -->
<%=varBend%></font>
</tbody>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p align="center"><a href="SUS.asp">HOME</a></p>

</body>

</html>
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 12

Expert Comment

by:rcmb
ID: 10933437
Found a few mistakes
Starting with <p align="center"> delete everything from that point and replace with the code after my initials.

I assume you wanted BuildStatus bracketed with the font color changes --

You had <font color=<%=varFontColor%>"><%=varBstart%></font>

which should read <font color="<%=varFontColor%>"><%=varBstart%> your data starts here

then after your data put <%=varBend%></font>

also you had the code beginning on the line for SystemRelease vice BuildStatus

RCMB

      <p align="center">
      <a href="suedit.asp?ReleaseID=<%=FP_FieldURL(fp_rs,"ReleaseID")%>">Edit</a></td>
      <td>
      <!--webbot bot="DatabaseResultColumn" s-columnnames="ReleaseID,SystemRelease,BuildStatus,GatingPtrs,CurrentBuildNum,NextBuildNum,PreviousGABuild,Comments" s-column="SystemRelease" b-tableformat="TRUE" b-hashtml="FALSE" b-makelink="FALSE" clientside b-MenuFormat preview="&lt;font size=&quot;-1&quot;&gt;&amp;lt;&amp;lt;&lt;/font&gt;SystemRelease&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"SystemRelease")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="36759" --></td>
      <td>
      <font color="<%=varFontColor%>"><%=varBstart%><!--webbot bot="DatabaseResultColumn" s-columnnames="ReleaseID,SystemRelease,BuildStatus,GatingPtrs,CurrentBuildNum,NextBuildNum,PreviousGABuild,Comments" s-column="BuildStatus" b-tableformat="TRUE" b-hashtml="FALSE" b-makelink="FALSE" clientside b-MenuFormat preview="&lt;font size=&quot;-1&quot;&gt;&amp;lt;&amp;lt;&lt;/font&gt;BuildStatus&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"BuildStatus")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="32721" --><%=varBend%></font></p>
      </td>
      <td>
      <!--webbot bot="DatabaseResultColumn" s-columnnames="ReleaseID,SystemRelease,BuildStatus,GatingPtrs,CurrentBuildNum,NextBuildNum,PreviousGABuild,Comments" s-column="GatingPtrs" b-tableformat="TRUE" b-hashtml="FALSE" b-makelink="FALSE" clientside b-MenuFormat preview="&lt;font size=&quot;-1&quot;&gt;&amp;lt;&amp;lt;&lt;/font&gt;GatingPtrs&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"GatingPtrs")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="29459" --></td>
      <td>
      <!--webbot bot="DatabaseResultColumn" s-columnnames="ReleaseID,SystemRelease,BuildStatus,GatingPtrs,CurrentBuildNum,NextBuildNum,PreviousGABuild,Comments" s-column="CurrentBuildNum" b-tableformat="TRUE" b-hashtml="FALSE" b-makelink="FALSE" clientside b-MenuFormat preview="&lt;font size=&quot;-1&quot;&gt;&amp;lt;&amp;lt;&lt;/font&gt;CurrentBuildNum&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"CurrentBuildNum")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="40737" --></td>
      <td>
      <!--webbot bot="DatabaseResultColumn" s-columnnames="ReleaseID,SystemRelease,BuildStatus,GatingPtrs,CurrentBuildNum,NextBuildNum,PreviousGABuild,Comments" s-column="NextBuildNum" b-tableformat="TRUE" b-hashtml="FALSE" b-makelink="FALSE" clientside b-MenuFormat preview="&lt;font size=&quot;-1&quot;&gt;&amp;lt;&amp;lt;&lt;/font&gt;NextBuildNum&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"NextBuildNum")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="27508" --></td>
      <td>
      <!--webbot bot="DatabaseResultColumn" s-columnnames="ReleaseID,SystemRelease,BuildStatus,GatingPtrs,CurrentBuildNum,NextBuildNum,PreviousGABuild,Comments" s-column="PreviousGABuild" b-tableformat="TRUE" b-hashtml="FALSE" b-makelink="FALSE" clientside b-MenuFormat preview="&lt;font size=&quot;-1&quot;&gt;&amp;lt;&amp;lt;&lt;/font&gt;PreviousGABuild&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"PreviousGABuild")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="34608" --></td>
      <td>
      <!--webbot bot="DatabaseResultColumn" s-columnnames="ReleaseID,SystemRelease,BuildStatus,GatingPtrs,CurrentBuildNum,NextBuildNum,PreviousGABuild,Comments" s-column="Comments" b-tableformat="TRUE" b-hashtml="FALSE" b-makelink="FALSE" clientside b-MenuFormat preview="&lt;font size=&quot;-1&quot;&gt;&amp;lt;&amp;lt;&lt;/font&gt;Comments&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"Comments")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="16369" --></td>
    </tr>
    <!--webbot bot="DatabaseRegionEnd" b-tableformat="TRUE" b-menuformat="FALSE" u-dbrgn2="_fpclass/fpdbrgn2.inc" i-groupsize="0" clientside tag="TBODY" preview="&lt;tr&gt;&lt;td colspan=64 bgcolor=&quot;#FFFF00&quot; width=&quot;100%&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;This is the end of a Database Results region.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;" startspan --><!--#include file="_fpclass/fpdbrgn2.inc"-->
<!--webbot bot="DatabaseRegionEnd" endspan i-checksum="62730" -->
<%=varBend%></font>
</tbody>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p align="center"><a href="SUS.asp">HOME</a></p>

</body>

</html>
0
 
LVL 12

Accepted Solution

by:
rcmb earned 500 total points
ID: 10933464
I just noticed another mistake

at the bottom of the page you will find

<%=varBend%></font>
</tbody>

Delete the <%=varBend%></font>

RCMB
0
 

Author Comment

by:tmurray22
ID: 10939044
Thanks RCMB,
 works like a champ. You know your FP.



tmurray22
0
 
LVL 12

Expert Comment

by:rcmb
ID: 10939309
Glad to help and hope you enjoy. The power of adding some VBScript to FP is unlimited. You can do things like alternate row colors, change background colors, show different pictures, etc. all based on the results of the db query.

Have fun and thanks for the points.

RCMB
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When deciding to adopt any help desk solutions many factors should be explored before taking decisions. This will change from business to another but in general there are some kind of rule of thumb. Here are some quick tips: Do we need only ticket…
Objective of This Article In 1990’s, when I was a budding software professional, I had a lot of confusion about which stream or technology, I had to choose to build my career. In those days, I had lot of confusion like whether to choose System so…
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question