?
Solved

CHange the row color depending on field valve

Posted on 2005-04-16
29
Medium Priority
?
291 Views
Last Modified: 2011-09-20
How can i change the color of the row both background and foreground, Depenind on a database field value

IE if field="Teacher" the colors = ******* else if field="Technicain" then color="********" etc

This needs to be done in asp if possible an keep it simple please me just starting out.

Stuart
0
Comment
Question by:rama1712
  • 14
  • 7
  • 4
  • +3
28 Comments
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 13797203
It should go something like this. If you post your code as you have it now, I'll take a look and modify it as below should you need help implementing this.

do while not objRS.EOF
     if objRS("fldOccupation") = "Teacher" then
         strColor = "Blue"
     else
         strColor="Red"
     end if
     response.write("<tr bgcolor='" & strColor & "'><td>" & objRS("fldOccupation")  & "</td></tr>")
    objRS.MoveNext()
loop

Fritz the Blank
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 13797261
Instead of bgColor I would define two styles in the head of the page, one for Teachers and one for Technicians, and assign the styles as class name to the <tr> tags.

0
 
LVL 63

Expert Comment

by:Zvonko
ID: 13797345
Here a tested example:

<html>
<head>
<style>
.teacher {
  color: blue;
  background-color: yellow;
}
.technician {
  color: yellow;
  background-color: green;
}
</style>
</head>
<body>
<table>
<%
  Dim arrTR(3)
  arrTR(1) = "Teacher: Mr. Peterson."
  arrTR(2) = "Technician: Mrs. Peterson."
  arrTR(3) = "Teacher: Mr. Smart."

  For i= 1 to UBound(arrTR)
    field = split(arrTR(i), ":")
    colors = ""
    If field(0)="Teacher" Then colors = "class='teacher'"
    If field(0)="Technician" Then colors = "class='technician'"
    %>
<tr <% = colors %>  ><td><% =field(1) %></td></tr>
    <%
  Next
%>
</table>
</body>
</html>


0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 63

Expert Comment

by:Zvonko
ID: 13797368
And if you want to give the else selection some default colors, then you could do it like this:

<html>
<head>
<style>
.default {
  color: blue;
  background-color: lightgray;
}
.teacher {
  color: blue;
  background-color: yellow;
}
.technician {
  color: yellow;
  background-color: green;
}
</style>
</head>
<body>
<table>
<%
  Dim arrTR(4)
  arrTR(1) = "Teacher: Mr. Peterson."
  arrTR(2) = "Technician: Mrs. Peterson."
  arrTR(3) = "Pupil: Mss. Child."
  arrTR(4) = "Teacher: Mr. Smart."

  For i= 1 to UBound(arrTR)
    field = split(arrTR(i), ":")
    colors = "class='default'"
    If field(0)="Teacher" Then colors = "class='teacher'"
    If field(0)="Technician" Then colors = "class='technician'"
    %>
<tr <% = colors %>><td><% =field(1) %></td></tr>
    <%
  Next
%>
</table>
</body>
</html>

0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 13797566
So you are essentially saying the same thing except that you want to define an inline CSS style sheet...

FtB
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 13797702
In either case, the basic idea is the same--you need to use an If statement to set the color of the row  conditionally. Now, we could use the background color like I suggested, or the inline CSS style like ZVonko suggested, we could create a class and apply that, we could point to an external CSS style sheet, we could create different cell classes and etc. and etc., but all of these solutions rely upon using the conditional logic to set the color.

FtB
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 13797830
true.
0
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 13798763
Except the poster inserted the infamous "ETC"

"""if field="Teacher" the colors = ******* else if field="Technicain" then color="********" etc"""

So maybe a select would be more appropriate???

do while not objRS.EOF
     SELECT Case LCase(objRS("fldOccupation"))
        Case "teacher"
           strColor = "#0000FF"
        Case "technician"
            strColor = "#FF0000"
        Case "etc" ' <grin>
            strColor = "#EEEEEE"
         Case Else
            strColor = "#FFEEEE"
       End SELECT
     end if
     response.write("<tr bgcolor='" & strColor & "'><td>" & objRS("fldOccupation")  & "</td></tr>")
    objRS.MoveNext()
loop

Regards,
Rod
0
 
LVL 2

Expert Comment

by:ryoga75
ID: 13798812
a fast way to do it .

Create a CSS like this :

.teacher {
  color: blue;
  background-color: white;
}
.technician {
  color: yellow;
  background-color: green;
}

and then in the code just add :

<% While not ObjRs.Eof %>
   <tr class='<%=ObjRs.Eof("fldOccupation")%>'><td><%=objRS("fldOccupation")%></td></tr>
<% ObjRs.Movenext
Wend %>

In this case there's no IF Statement and no unuseful code :)
HTH
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 13798855
>>and no unuseful code <<

If the code does something, then indeed it is useful rather than superfluous.

BTW, a typo in your code--you can't mean this:

ObjRs.Eof("fldOccupation")

but must mean this:

ObjRs("fldOccupation")%

So:

<tr class='<%=ObjRs("fldOccupation")%>'><td><%=objRS("fldOccupation")%></td></tr>

Now, to your point about avoiding the If/End IF logic, your code does indeed solve that problem but only at the expense if referencing the recordset object field twice. So, if you are really, really that concerned about efficency, then this would be better still:

Create a CSS like this :

.teacher {
  color: blue;
  background-color: white;
}
.technician {
  color: yellow;
  background-color: green;
}

and then in the code just add :

<%
Do while not ObjRs.Eof
%>
   strProfession = objRS("fldOccupation")
   <tr class='<%=strProfession%>'><td><%=strProfession%></td></tr>
<%
   ObjRs.Movenext
Loop
%>

Of course, alll of this just seems to be trying to do the same thing different ways as indicated in:

http://www.experts-exchange.com/help.jsp#hi241
http://www.experts-exchange.com/help.jsp#hi242

FtB
0
 

Author Comment

by:rama1712
ID: 13799006
THese are all great sugestions and i will try and insert them, but as i said I am new to asp and just wondering where in asp should this be inserted in my page.

Here is a copy of the page 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>tblStaffList -- View</title>
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
</head>

<body bgcolor="#FFFFFF">

<table width="100%" border="1">
      <thead>
            <tr>
                  <th ALIGN="LEFT"><b>Initials</b></th>
                  <th ALIGN="LEFT"><b>Surname</b></th>
                  <th ALIGN="LEFT"><b>Firstname</b></th>
                  <th ALIGN="LEFT"><b>Staff Type</b></th>
                  <th ALIGN="LEFT"><b>Department</b></th>
                  <th ALIGN="LEFT"><b>Room</b></th>
                  <th ALIGN="LEFT"><b>Other Info</b></th>
            </tr>
      </thead>
      <tbody>
            <!--webbot bot="DatabaseRegionStart" s-columnnames="ID,Intials,Surname,Firstname,fldType,Department,Room,OtherInfo" s-columntypes="3,202,202,202,202,202,202,202" s-dataconnection="Stafflist" b-tableformat="TRUE" b-menuformat="FALSE" s-menuchoice="Intials" s-menuvalue="Intials" b-tableborder="TRUE" b-tableexpand="TRUE" b-tableheader="TRUE" b-listlabels="TRUE" b-listseparator="TRUE" i-listformat="0" b-makeform="FALSE" s-recordsource="tblStaffList" s-displaycolumns="Intials,Surname,Firstname,fldType,Department,Room,OtherInfo" s-criteria s-order s-sql="SELECT * FROM tblStaffList" 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;" b-UseDotNET="FALSE" CurrentExt sa-InputTypes b-DataGridFormat="FALSE" b-DGridAlternate="TRUE" sa-CritTypes b-WasTableFormat="TRUE" 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 tblStaffList"
fp_sDefault=""
fp_sNoRecords="<tr><td colspan=7 align=""LEFT"" width=""100%"">No records returned.</td></tr>"
fp_sDataConn="Stafflist"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice="Intials"
fp_sMenuValue="Intials"
fp_sColTypes="&ID=3&Intials=202&Surname=202&Firstname=202&fldType=202&Department=202&Room=202&OtherInfo=202&"
fp_iDisplayCols=7
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="../_fpclass/fpdbrgn1.inc"-->
<!--webbot bot="DatabaseRegionStart" endspan i-checksum="52067" --><tr>
                  <td>
                  <!--webbot bot="DatabaseResultColumn" s-columnnames="ID,Intials,Surname,Firstname,fldType,Department,Room,OtherInfo" s-column="Intials" 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;Intials&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"Intials")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="13821" --></td>
                  <td>
                  <!--webbot bot="DatabaseResultColumn" s-columnnames="ID,Intials,Surname,Firstname,fldType,Department,Room,OtherInfo" s-column="Surname" 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;Surname&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"Surname")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="15149" --></td>
                  <td>
                  <!--webbot bot="DatabaseResultColumn" s-columnnames="ID,Intials,Surname,Firstname,fldType,Department,Room,OtherInfo" s-column="Firstname" 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;Firstname&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"Firstname")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="18968" --></td>
                  <td>
                  <!--webbot bot="DatabaseResultColumn" s-columnnames="ID,Intials,Surname,Firstname,fldType,Department,Room,OtherInfo" s-column="fldType" 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;fldType&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"fldType")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="15267" --></td>
                  <td>
                  <!--webbot bot="DatabaseResultColumn" s-columnnames="ID,Intials,Surname,Firstname,fldType,Department,Room,OtherInfo" s-column="Department" 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;Department&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"Department")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="29735" --></td>
                  <td>
                  <!--webbot bot="DatabaseResultColumn" s-columnnames="ID,Intials,Surname,Firstname,fldType,Department,Room,OtherInfo" s-column="Room" 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;Room&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"Room")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="5966" --></td>
                  <td>
                  <!--webbot bot="DatabaseResultColumn" s-columnnames="ID,Intials,Surname,Firstname,fldType,Department,Room,OtherInfo" s-column="OtherInfo" 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;OtherInfo&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"OtherInfo")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="21234" --></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="56926" --></tbody>
</table>

<table width="100%" align=left id="table1">
  <tr>
    <td width="22%" align=right>
      <table id="table2">
        <tr>
          <td>
            Results Page
| <a href="editor/submission_form.asp" target="_top">Submission Form</a>
| <a href="editor/database_editor.asp" target="_top">Database Editor</a>
          </td>
        </tr>
      </table>
      </td>
  </tr>
</table>


</body>

</html>
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 13799056
There are a number of suggestions here, but I sensed from your question that you are a beginner and I am trying to keep things simple.

Your page might look something like this:

<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>tblStaffList -- View</title>
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
</head>

<body bgcolor="#FFFFFF">

<table width="100%" border="1">
     <thead>
          <tr>
               <th ALIGN="LEFT"><b>Initials</b></th>
               <th ALIGN="LEFT"><b>Surname</b></th>
               <th ALIGN="LEFT"><b>Firstname</b></th>
               <th ALIGN="LEFT"><b>Staff Type</b></th>
               <th ALIGN="LEFT"><b>Department</b></th>
               <th ALIGN="LEFT"><b>Room</b></th>
               <th ALIGN="LEFT"><b>Other Info</b></th>
          </tr>
     </thead>
     <tbody>
          <!--webbot bot="DatabaseRegionStart" s-columnnames="ID,Intials,Surname,Firstname,fldType,Department,Room,OtherInfo" s-columntypes="3,202,202,202,202,202,202,202" s-dataconnection="Stafflist" b-tableformat="TRUE" b-menuformat="FALSE" s-menuchoice="Intials" s-menuvalue="Intials" b-tableborder="TRUE" b-tableexpand="TRUE" b-tableheader="TRUE" b-listlabels="TRUE" b-listseparator="TRUE" i-listformat="0" b-makeform="FALSE" s-recordsource="tblStaffList" s-displaycolumns="Intials,Surname,Firstname,fldType,Department,Room,OtherInfo" s-criteria s-order s-sql="SELECT * FROM tblStaffList" 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;" b-UseDotNET="FALSE" CurrentExt sa-InputTypes b-DataGridFormat="FALSE" b-DGridAlternate="TRUE" sa-CritTypes b-WasTableFormat="TRUE" 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 tblStaffList"
fp_sDefault=""
fp_sNoRecords="<tr><td colspan=7 align=""LEFT"" width=""100%"">No records returned.</td></tr>"
fp_sDataConn="Stafflist"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice="Intials"
fp_sMenuValue="Intials"
fp_sColTypes="&ID=3&Intials=202&Surname=202&Firstname=202&fldType=202&Department=202&Room=202&OtherInfo=202&"
fp_iDisplayCols=7
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="../_fpclass/fpdbrgn1.inc"-->
<!--webbot bot="DatabaseRegionStart" endspan i-checksum="52067" -->
<%
strRowColor = "White
if Upper(FP_FieldVal(fp_rs,"fldType")) = "TEACHER" then
      strRowColor = "Red"
end if
if Upper(FP_FieldVal(fp_rs,"fldType")) = "TECHNICIAN" then
      strRowColor = "Green"
end if

%>
<tr bgcolor="<%=strRowColor%>">
               <td>
               <!--webbot bot="DatabaseResultColumn" s-columnnames="ID,Intials,Surname,Firstname,fldType,Department,Room,OtherInfo" s-column="Intials" 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;Intials&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"Intials")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="13821" --></td>
               <td>
               <!--webbot bot="DatabaseResultColumn" s-columnnames="ID,Intials,Surname,Firstname,fldType,Department,Room,OtherInfo" s-column="Surname" 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;Surname&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"Surname")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="15149" --></td>
               <td>
               <!--webbot bot="DatabaseResultColumn" s-columnnames="ID,Intials,Surname,Firstname,fldType,Department,Room,OtherInfo" s-column="Firstname" 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;Firstname&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"Firstname")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="18968" --></td>
               <td>
               <!--webbot bot="DatabaseResultColumn" s-columnnames="ID,Intials,Surname,Firstname,fldType,Department,Room,OtherInfo" s-column="fldType" 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;fldType&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"fldType")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="15267" --></td>
               <td>
               <!--webbot bot="DatabaseResultColumn" s-columnnames="ID,Intials,Surname,Firstname,fldType,Department,Room,OtherInfo" s-column="Department" 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;Department&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"Department")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="29735" --></td>
               <td>
               <!--webbot bot="DatabaseResultColumn" s-columnnames="ID,Intials,Surname,Firstname,fldType,Department,Room,OtherInfo" s-column="Room" 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;Room&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"Room")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="5966" --></td>
               <td>
               <!--webbot bot="DatabaseResultColumn" s-columnnames="ID,Intials,Surname,Firstname,fldType,Department,Room,OtherInfo" s-column="OtherInfo" 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;OtherInfo&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"OtherInfo")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="21234" --></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="56926" --></tbody>
</table>

<table width="100%" align=left id="table1">
  <tr>
    <td width="22%" align=right>
      <table id="table2">
        <tr>
          <td>
          Results Page
| <a href="editor/submission_form.asp" target="_top">Submission Form</a>
| <a href="editor/database_editor.asp" target="_top">Database Editor</a>
          </td>
        </tr>
      </table>
     </td>
  </tr>
</table>


</body>

</html>
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 13799071
Just so you can keep track, the changes I made are here:

<!--webbot bot="DatabaseRegionStart" endspan i-checksum="52067" -->
<%
strRowColor = "White
if Upper(FP_FieldVal(fp_rs,"fldType")) = "TEACHER" then
     strRowColor = "Red"
end if
if Upper(FP_FieldVal(fp_rs,"fldType")) = "TECHNICIAN" then
     strRowColor = "Green"
end if

%>
<tr bgcolor="<%=strRowColor%>">


As an aside, if there are many colors, then I agree with rdivilbiss's post in http:#13798763 that using the SELECT CASE statement may be the best way to go as it is more efficient. What I have above is meant to be the most simple to get you started.

FtB
0
 

Author Comment

by:rama1712
ID: 13799128
tried the above and it does not work it comes up with
An error occurred on the server when processing the URL. Please contact the system administrator.

on web page

Stuart
0
 

Author Comment

by:rama1712
ID: 13799129
Where in code would i put the select case?
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 13799159
How about we get the simpler code working first and then we will try to go for the more complicated solution.

Did this page work before you made the change?

FtB
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 13799199
But if it will help you to focus, here is the code again using the select case as rdivilbiss suggested:

<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>tblStaffList -- View</title>
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
</head>

<body bgcolor="#FFFFFF">

<table width="100%" border="1">
     <thead>
          <tr>
               <th ALIGN="LEFT"><b>Initials</b></th>
               <th ALIGN="LEFT"><b>Surname</b></th>
               <th ALIGN="LEFT"><b>Firstname</b></th>
               <th ALIGN="LEFT"><b>Staff Type</b></th>
               <th ALIGN="LEFT"><b>Department</b></th>
               <th ALIGN="LEFT"><b>Room</b></th>
               <th ALIGN="LEFT"><b>Other Info</b></th>
          </tr>
     </thead>
     <tbody>
          <!--webbot bot="DatabaseRegionStart" s-columnnames="ID,Intials,Surname,Firstname,fldType,Department,Room,OtherInfo" s-columntypes="3,202,202,202,202,202,202,202" s-dataconnection="Stafflist" b-tableformat="TRUE" b-menuformat="FALSE" s-menuchoice="Intials" s-menuvalue="Intials" b-tableborder="TRUE" b-tableexpand="TRUE" b-tableheader="TRUE" b-listlabels="TRUE" b-listseparator="TRUE" i-listformat="0" b-makeform="FALSE" s-recordsource="tblStaffList" s-displaycolumns="Intials,Surname,Firstname,fldType,Department,Room,OtherInfo" s-criteria s-order s-sql="SELECT * FROM tblStaffList" 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;" b-UseDotNET="FALSE" CurrentExt sa-InputTypes b-DataGridFormat="FALSE" b-DGridAlternate="TRUE" sa-CritTypes b-WasTableFormat="TRUE" 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 tblStaffList"
fp_sDefault=""
fp_sNoRecords="<tr><td colspan=7 align=""LEFT"" width=""100%"">No records returned.</td></tr>"
fp_sDataConn="Stafflist"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice="Intials"
fp_sMenuValue="Intials"
fp_sColTypes="&ID=3&Intials=202&Surname=202&Firstname=202&fldType=202&Department=202&Room=202&OtherInfo=202&"
fp_iDisplayCols=7
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="../_fpclass/fpdbrgn1.inc"-->
<!--webbot bot="DatabaseRegionStart" endspan i-checksum="52067" -->
<%
select case Upper(FP_FieldVal(fp_rs,"fldType"))
      case "TEACHER
            strRowColor = "Red"
      case "TECHNICIAN
            strRowColor = "Green"
      case else
            strRowColor = "White"
end select
%>
<tr bgcolor="<%=strRowColor%>">
               <td>
               <!--webbot bot="DatabaseResultColumn" s-columnnames="ID,Intials,Surname,Firstname,fldType,Department,Room,OtherInfo" s-column="Intials" 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;Intials&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"Intials")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="13821" --></td>
               <td>
               <!--webbot bot="DatabaseResultColumn" s-columnnames="ID,Intials,Surname,Firstname,fldType,Department,Room,OtherInfo" s-column="Surname" 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;Surname&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"Surname")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="15149" --></td>
               <td>
               <!--webbot bot="DatabaseResultColumn" s-columnnames="ID,Intials,Surname,Firstname,fldType,Department,Room,OtherInfo" s-column="Firstname" 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;Firstname&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"Firstname")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="18968" --></td>
               <td>
               <!--webbot bot="DatabaseResultColumn" s-columnnames="ID,Intials,Surname,Firstname,fldType,Department,Room,OtherInfo" s-column="fldType" 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;fldType&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"fldType")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="15267" --></td>
               <td>
               <!--webbot bot="DatabaseResultColumn" s-columnnames="ID,Intials,Surname,Firstname,fldType,Department,Room,OtherInfo" s-column="Department" 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;Department&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"Department")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="29735" --></td>
               <td>
               <!--webbot bot="DatabaseResultColumn" s-columnnames="ID,Intials,Surname,Firstname,fldType,Department,Room,OtherInfo" s-column="Room" 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;Room&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"Room")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="5966" --></td>
               <td>
               <!--webbot bot="DatabaseResultColumn" s-columnnames="ID,Intials,Surname,Firstname,fldType,Department,Room,OtherInfo" s-column="OtherInfo" 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;OtherInfo&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"OtherInfo")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="21234" --></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="56926" --></tbody>
</table>

<table width="100%" align=left id="table1">
  <tr>
    <td width="22%" align=right>
      <table id="table2">
        <tr>
          <td>
          Results Page
| <a href="editor/submission_form.asp" target="_top">Submission Form</a>
| <a href="editor/database_editor.asp" target="_top">Database Editor</a>
          </td>
        </tr>
      </table>
     </td>
  </tr>
</table>


</body>

</html>
0
 

Author Comment

by:rama1712
ID: 13800558
Yes the web page works with out any of the row colours it displays all the records in the database but as soon as i end any of these row change colours i get the following error

An error occurred on the server when processing the URL. Please contact the system administrator.

I have copyed all the code from above and still get same error.

What if i send you a copy of all my pages and database??

my own email is stuart@xxxyyy.com

Stuart
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 13800782
Emailing me this would not help since I can't really duplicate your environment. The big problem is that you are using FrontPage, and that doesn't always play well..

Did  the second code snippet that I posted throw an error as well?

FtB
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 13800795
What if you change the code to this:

<%
select case Upper(fp_rs("fldType"))
     case "TEACHER
          strRowColor = "Red"
     case "TECHNICIAN
          strRowColor = "Green"
     case else
          strRowColor = "White"
end select
%>
0
 

Author Comment

by:rama1712
ID: 13800861
No still not work I am going to close the call and forget about it.

0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 13800877
My best advice, stop using FrontPage and learn how to code this by hand. I started by using FrontPage, but became increasingly frustrated with all of the problems it caused--just like you are having now.

FtB
0
 

Author Comment

by:rama1712
ID: 13800928
Unfort we are unable to do this as weare school and pupils have got to be able to modify pages etc and Frontpage gives us the better flexablity.

So far it has do everthing else we need to do.

So Frontpage will have to be it. and as my main field is NEtwork MAnagement I have just been given this as a extra work I do not have the willing or time to learn code from scratch.

I do have dreamweaver could i do anything with this.

Stuart
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 13800945
If you recreate this page in DW, I can modify the code to do what you want it to.

Be warned, though, that if you create this in DW, you won't be able to modify it in FP.

FtB
0
 
LVL 10

Expert Comment

by:ThaSmartUno
ID: 13806201
just so you can see the error you are getting you have to turn off friendly HTTP Error messages ...

Tools > Internet Options .... Advanced tab  
UnCheck Friendly HTTP Error Messages

(This should let you know more about the error)
0
 
LVL 46

Accepted Solution

by:
fritz_the_blank earned 2000 total points
ID: 13809363
I think that I know what the problem is--in order to check for a recordset value in FP, you need to have code such as the following:

<td>
               <!--webbot bot="DatabaseResultColumn" s-columnnames="ID,Intials,Surname,Firstname,fldType,Department,Room,OtherInfo" s-column="Intials" 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;Intials&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"Intials")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="13821" --></td>


Now the problem is that I don't know how to determine the appropriate checksum number and etc. It is an inherent problem in FP--it doesn't allow you to modify the auto-generated code. Indeed, it offers the following in the page:

<% ' 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">


I have modified DW code of this sort without issue.

FtB
0
 

Author Comment

by:rama1712
ID: 13810571
I think i and you have spent enough time on this problem I am going to call it quits.

I do not know enough about Dreamweaver to re do the pages and i do not have the time any more, I am just so suprised that this simple thing cannot be done I have even tried the mS fourms and no help there.

I will just color the table and hope it looks okay as is

Thanks for all help

Stuart
I will award the point to FTB for all effort he has put in.

TTFN
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 13850161
I am sorry that this did not work out.

FtB
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Integration Management Part 2

864 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