Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Where do i put my If..Then..Else statment?

Status
Not open for further replies.

crashc123

Technical User
Oct 3, 2001
80
US
I am calling a table from my database. I want to color the rows that have today's date in the due date. Where would I put the statement for this.

Here's what I have but it doesn't change the background color.


<%
Do While Not rstDBEdit.EOF

Dim ComDate 'Comparison Date, Today's date
Dim vbShortDate
vbShortDate = 2
ComDate= FormatDateTime(Now,vbShortDate) 'So the date will be mm/dd/yyyy

If rstDBEdit.Fields(&quot;DateDue&quot;)= ComDate Then
Response.Write &quot;<tr bcolor = orange>&quot;
Else
Response.Write &quot;<tr>&quot;
End If
%>
<td width=&quot;2%&quot;><%= rstDBEdit.Fields(&quot;ID&quot;).Value %> </td>
<td width=&quot;4%&quot;><%= rstDBEdit.Fields(&quot;JobNo&quot;).Value %> </td>
<td width=&quot;10%&quot;><%= rstDBEdit.Fields(&quot;Title&quot;).Value %> </td>
<td width=&quot;40%&quot;><%= rstDBEdit.Fields(&quot;Description&quot;).Value %> </td>
<td width=&quot;5%&quot;><%= rstDBEdit.Fields(&quot;Aircraft&quot;).Value %> </td>
<td width=&quot;6%&quot;><%= rstDBEdit.Fields(&quot;JobType&quot;).Value %> </td>
<td width=&quot;6%&quot;><%= rstDBEdit.Fields(&quot;Engineer&quot;).Value %> </td>
<td width=&quot;6%&quot;><%= rstDBEdit.Fields(&quot;Focal&quot;).Value %> </td>
<td width=&quot;6%&quot;><%= rstDBEdit.Fields(&quot;DER&quot;).Value %> </td>
<td width=&quot;3%&quot;><%= rstDBEdit.Fields(&quot;DateIn&quot;).Value %> </td>
<td width=&quot;3%&quot;><%= rstDBEdit.Fields(&quot;DateDue&quot;).Value %> </td>
<td width=&quot;3%&quot;><%= rstDBEdit.Fields(&quot;EightyoneDue&quot;).Value %> </td>
<td width=&quot;3%&quot;><%= rstDBEdit.Fields(&quot;DTRDue&quot;).Value %> </td>
<td width=&quot;3%&quot;><a href=&quot;<%= SCRIPT_NAME %>?action=delete&id=<%= rstDBEdit.Fields(&quot;id&quot;).Value %>&quot;>Delete</a></td>
<td width=&quot;3%&quot;><a href=&quot;<%= SCRIPT_NAME %>?action=edit&id=<%= rstDBEdit.Fields(&quot;id&quot;).Value %>&quot;>Edit</a></td>
</tr>
<%
rstDBEdit.MoveNext
Loop
 
Ahhh...the elusive alternating row color trick!

Here's a simple If...Then construct you could use:
<%
Do While Not rstDBEdit.EOF
If alternatingcolor = &quot;orange&quot; Then
alternatingcolor = &quot;white&quot;
Else
alternatingcolor = &quot;orange&quot;
End If
Response.Write &quot;<tr bgcolor='&quot; & alternatingcolor & &quot;'>
''''''''''''''''''''''''''''
' MORE DB stuff here......
''''''''''''''''''''''''''''
rstDBEdit.MoveNext
Loop
%>
 
crashc123,

Your own code will work fine - you just have a small error.
You have:

&quot;<tr bcolor = orange>&quot;

It should be:

&quot;<tr bgcolor = orange>&quot;

Mise Le Meas,

Mighty :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top