Database Results background color.

J

Jeff

Does anyone know how to change the background color in the database results
table based on the results in a field?

I have a column (on an ASP Intranet Page) that displays the date for each
item entered into the database.

I would like to change the background color of this column for every day
except for the current day(today). This is to distinguish todays activity
from all other days.

I came up with the following code but it's not working correctly. The result
I get now is the background color is the FFCC77color for all days, including
today. The gray color will not come up for todays entries.


<%
EntryDate = date()
if EntryDate = (request.querystring("Entry_Date")) then
bgcolor="gray"
else
bgcolor="FFCC77"
end if %>


Any ideas?

Thanks,

Jeff
 
B

Bob

The only thing I have used is alternating color...
How To: Adding VBScript to ASP page to alternate row colors in FrontPage
Database Results Wizard query results

Info Here....
http://www.spiderwebwoman.com/tutorials/alt_row_colors.htm

You might also want to look here

http://www.spiderwebwoman.com/resources/dbrwtipsandtricks.asp

One of the best resources I have used...

bob
| Does anyone know how to change the background color in the database
results
| table based on the results in a field?
|
| I have a column (on an ASP Intranet Page) that displays the date for each
| item entered into the database.
|
| I would like to change the background color of this column for every day
| except for the current day(today). This is to distinguish todays activity
| from all other days.
|
| I came up with the following code but it's not working correctly. The
result
| I get now is the background color is the FFCC77color for all days,
including
| today. The gray color will not come up for todays entries.
|
|
| <%
| EntryDate = date()
| if EntryDate = (request.querystring("Entry_Date")) then
| bgcolor="gray"
| else
| bgcolor="FFCC77"
| end if %>
|
|
| Any ideas?
|
| Thanks,
|
| Jeff
 
S

Stefan B Rusynko

Try
<%
EntryDate = date()
if EntryDate = (request.querystring("Entry_Date")) then
cellcolor= "bgcolor='gray'"
else
cellcolor= "bgcolor='FFCC77'"
end if
%>

Then in your table set the cell as
<td <%=cellcolor%>>

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| Does anyone know how to change the background color in the database results
| table based on the results in a field?
|
| I have a column (on an ASP Intranet Page) that displays the date for each
| item entered into the database.
|
| I would like to change the background color of this column for every day
| except for the current day(today). This is to distinguish todays activity
| from all other days.
|
| I came up with the following code but it's not working correctly. The result
| I get now is the background color is the FFCC77color for all days, including
| today. The gray color will not come up for todays entries.
|
|
| <%
| EntryDate = date()
| if EntryDate = (request.querystring("Entry_Date")) then
| bgcolor="gray"
| else
| bgcolor="FFCC77"
| end if %>
|
|
| Any ideas?
|
| Thanks,
|
| Jeff
 
J

Jeff

Thanks for the response, but no luck. I'm still getting the same results. All
of the cells still come up the same color.

Jeff
 
S

Stefan B Rusynko

Make sure (request.querystring("Entry_Date")) is a valid date format

Add before
EntryDate = date()

if IsDate request.querystring("Entry_Date") then Cdate(request.querystring("Entry_Date"))
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| Thanks for the response, but no luck. I'm still getting the same results. All
| of the cells still come up the same color.
|
| Jeff
|
|
| "Stefan B Rusynko" wrote:
|
| > Try
| > <%
| > EntryDate = date()
| > if EntryDate = (request.querystring("Entry_Date")) then
| > cellcolor= "bgcolor='gray'"
| > else
| > cellcolor= "bgcolor='FFCC77'"
| > end if
| > %>
| >
| > Then in your table set the cell as
| > <td <%=cellcolor%>>
| >
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > To find the best Newsgroup for FrontPage support see:
| > http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| > _____________________________________________
| >
| >
| > | Does anyone know how to change the background color in the database results
| > | table based on the results in a field?
| > |
| > | I have a column (on an ASP Intranet Page) that displays the date for each
| > | item entered into the database.
| > |
| > | I would like to change the background color of this column for every day
| > | except for the current day(today). This is to distinguish todays activity
| > | from all other days.
| > |
| > | I came up with the following code but it's not working correctly. The result
| > | I get now is the background color is the FFCC77color for all days, including
| > | today. The gray color will not come up for todays entries.
| > |
| > |
| > | <%
| > | EntryDate = date()
| > | if EntryDate = (request.querystring("Entry_Date")) then
| > | bgcolor="gray"
| > | else
| > | bgcolor="FFCC77"
| > | end if %>
| > |
| > |
| > | Any ideas?
| > |
| > | Thanks,
| > |
| > | Jeff
| >
| >
| >
 
J

Jeff

Here is what my code looks like now per your suggestion. (I hope this is what
you meant)

<%
if IsDate request.querystring("Entry_Date") then
Cdate(request.querystring("Entry_Date"))
EntryDate = date()
if EntryDate = (request.querystring("Entry_Date")) then
cellcolor= "bgcolor='gray'"
else
cellcolor= "bgcolor='FFCC77'"
end if
%>

<td <%=cellcolor%>>

Now I get this error when I view my asp page:

Microsoft VBScript compilation error '800a03f9'

Expected 'Then'

/allsigninstestbgcolor.asp, line 152

if IsDate request.querystring("Entry_Date") then
Cdate(request.querystring("Entry_Date"))
----------^


Jeff



Stefan B Rusynko said:
Make sure (request.querystring("Entry_Date")) is a valid date format

Add before
EntryDate = date()

if IsDate request.querystring("Entry_Date") then Cdate(request.querystring("Entry_Date"))
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| Thanks for the response, but no luck. I'm still getting the same results. All
| of the cells still come up the same color.
|
| Jeff
|
|
| "Stefan B Rusynko" wrote:
|
| > Try
| > <%
| > EntryDate = date()
| > if EntryDate = (request.querystring("Entry_Date")) then
| > cellcolor= "bgcolor='gray'"
| > else
| > cellcolor= "bgcolor='FFCC77'"
| > end if
| > %>
| >
| > Then in your table set the cell as
| > <td <%=cellcolor%>>
| >
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > To find the best Newsgroup for FrontPage support see:
| > http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| > _____________________________________________
| >
| >
| > | Does anyone know how to change the background color in the database results
| > | table based on the results in a field?
| > |
| > | I have a column (on an ASP Intranet Page) that displays the date for each
| > | item entered into the database.
| > |
| > | I would like to change the background color of this column for every day
| > | except for the current day(today). This is to distinguish todays activity
| > | from all other days.
| > |
| > | I came up with the following code but it's not working correctly. The result
| > | I get now is the background color is the FFCC77color for all days, including
| > | today. The gray color will not come up for todays entries.
| > |
| > |
| > | <%
| > | EntryDate = date()
| > | if EntryDate = (request.querystring("Entry_Date")) then
| > | bgcolor="gray"
| > | else
| > | bgcolor="FFCC77"
| > | end if %>
| > |
| > |
| > | Any ideas?
| > |
| > | Thanks,
| > |
| > | Jeff
| >
| >
| >
 
S

Stefan B Rusynko

Sorry, My error
Redo as
<%
EntryDate = date()
If IsDate(request.querystring("Entry_Date")) Then
Entry_date = Cdate(request.querystring("Entry_Date"))
If EntryDate = Entry_date Then cellcolor= "bgcolor='gray'"
Else
cellcolor= "bgcolor='FFCC77'"
End if
%>
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| Here is what my code looks like now per your suggestion. (I hope this is what
| you meant)
|
| <%
| if IsDate request.querystring("Entry_Date") then
| Cdate(request.querystring("Entry_Date"))
| EntryDate = date()
| if EntryDate = (request.querystring("Entry_Date")) then
| cellcolor= "bgcolor='gray'"
| else
| cellcolor= "bgcolor='FFCC77'"
| end if
| %>
|
| <td <%=cellcolor%>>
|
| Now I get this error when I view my asp page:
|
| Microsoft VBScript compilation error '800a03f9'
|
| Expected 'Then'
|
| /allsigninstestbgcolor.asp, line 152
|
| if IsDate request.querystring("Entry_Date") then
| Cdate(request.querystring("Entry_Date"))
| ----------^
|
|
| Jeff
|
|
|
| "Stefan B Rusynko" wrote:
|
| > Make sure (request.querystring("Entry_Date")) is a valid date format
| >
| > Add before
| > EntryDate = date()
| >
| > if IsDate request.querystring("Entry_Date") then Cdate(request.querystring("Entry_Date"))
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > To find the best Newsgroup for FrontPage support see:
| > http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| > _____________________________________________
| >
| >
| > | Thanks for the response, but no luck. I'm still getting the same results. All
| > | of the cells still come up the same color.
| > |
| > | Jeff
| > |
| > |
| > | "Stefan B Rusynko" wrote:
| > |
| > | > Try
| > | > <%
| > | > EntryDate = date()
| > | > if EntryDate = (request.querystring("Entry_Date")) then
| > | > cellcolor= "bgcolor='gray'"
| > | > else
| > | > cellcolor= "bgcolor='FFCC77'"
| > | > end if
| > | > %>
| > | >
| > | > Then in your table set the cell as
| > | > <td <%=cellcolor%>>
| > | >
| > | > --
| > | >
| > | > _____________________________________________
| > | > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > | > "Warning - Using the F1 Key will not break anything!" (-;
| > | > To find the best Newsgroup for FrontPage support see:
| > | > http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| > | > _____________________________________________
| > | >
| > | >
| > | > | Does anyone know how to change the background color in the database results
| > | > | table based on the results in a field?
| > | > |
| > | > | I have a column (on an ASP Intranet Page) that displays the date for each
| > | > | item entered into the database.
| > | > |
| > | > | I would like to change the background color of this column for every day
| > | > | except for the current day(today). This is to distinguish todays activity
| > | > | from all other days.
| > | > |
| > | > | I came up with the following code but it's not working correctly. The result
| > | > | I get now is the background color is the FFCC77color for all days, including
| > | > | today. The gray color will not come up for todays entries.
| > | > |
| > | > |
| > | > | <%
| > | > | EntryDate = date()
| > | > | if EntryDate = (request.querystring("Entry_Date")) then
| > | > | bgcolor="gray"
| > | > | else
| > | > | bgcolor="FFCC77"
| > | > | end if %>
| > | > |
| > | > |
| > | > | Any ideas?
| > | > |
| > | > | Thanks,
| > | > |
| > | > | Jeff
| > | >
| > | >
| > | >
| >
| >
| >
 
J

Jeff

Stefan,

Thanks for sticking with me on this. I'm still getting the same results. All
of the cells are the same color.

Jeff

Stefan B Rusynko said:
Sorry, My error
Redo as
<%
EntryDate = date()
If IsDate(request.querystring("Entry_Date")) Then
Entry_date = Cdate(request.querystring("Entry_Date"))
If EntryDate = Entry_date Then cellcolor= "bgcolor='gray'"
Else
cellcolor= "bgcolor='FFCC77'"
End if
%>
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| Here is what my code looks like now per your suggestion. (I hope this is what
| you meant)
|
| <%
| if IsDate request.querystring("Entry_Date") then
| Cdate(request.querystring("Entry_Date"))
| EntryDate = date()
| if EntryDate = (request.querystring("Entry_Date")) then
| cellcolor= "bgcolor='gray'"
| else
| cellcolor= "bgcolor='FFCC77'"
| end if
| %>
|
| <td <%=cellcolor%>>
|
| Now I get this error when I view my asp page:
|
| Microsoft VBScript compilation error '800a03f9'
|
| Expected 'Then'
|
| /allsigninstestbgcolor.asp, line 152
|
| if IsDate request.querystring("Entry_Date") then
| Cdate(request.querystring("Entry_Date"))
| ----------^
|
|
| Jeff
|
|
|
| "Stefan B Rusynko" wrote:
|
| > Make sure (request.querystring("Entry_Date")) is a valid date format
| >
| > Add before
| > EntryDate = date()
| >
| > if IsDate request.querystring("Entry_Date") then Cdate(request.querystring("Entry_Date"))
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > To find the best Newsgroup for FrontPage support see:
| > http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| > _____________________________________________
| >
| >
| > | Thanks for the response, but no luck. I'm still getting the same results. All
| > | of the cells still come up the same color.
| > |
| > | Jeff
| > |
| > |
| > | "Stefan B Rusynko" wrote:
| > |
| > | > Try
| > | > <%
| > | > EntryDate = date()
| > | > if EntryDate = (request.querystring("Entry_Date")) then
| > | > cellcolor= "bgcolor='gray'"
| > | > else
| > | > cellcolor= "bgcolor='FFCC77'"
| > | > end if
| > | > %>
| > | >
| > | > Then in your table set the cell as
| > | > <td <%=cellcolor%>>
| > | >
| > | > --
| > | >
| > | > _____________________________________________
| > | > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > | > "Warning - Using the F1 Key will not break anything!" (-;
| > | > To find the best Newsgroup for FrontPage support see:
| > | > http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| > | > _____________________________________________
| > | >
| > | >
| > | > | Does anyone know how to change the background color in the database results
| > | > | table based on the results in a field?
| > | > |
| > | > | I have a column (on an ASP Intranet Page) that displays the date for each
| > | > | item entered into the database.
| > | > |
| > | > | I would like to change the background color of this column for every day
| > | > | except for the current day(today). This is to distinguish todays activity
| > | > | from all other days.
| > | > |
| > | > | I came up with the following code but it's not working correctly. The result
| > | > | I get now is the background color is the FFCC77color for all days, including
| > | > | today. The gray color will not come up for todays entries.
| > | > |
| > | > |
| > | > | <%
| > | > | EntryDate = date()
| > | > | if EntryDate = (request.querystring("Entry_Date")) then
| > | > | bgcolor="gray"
| > | > | else
| > | > | bgcolor="FFCC77"
| > | > | end if %>
| > | > |
| > | > |
| > | > | Any ideas?
| > | > |
| > | > | Thanks,
| > | > |
| > | > | Jeff
| > | >
| > | >
| > | >
| >
| >
| >
 
S

Stefan B Rusynko

Then your form field Entry_Date is not a valid date
Test your results
Add a debug line at the end

Response.write "Entry_Date = " & Entry_Date & " and data type is " & TypeName(Entry_Date)


--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| Stefan,
|
| Thanks for sticking with me on this. I'm still getting the same results. All
| of the cells are the same color.
|
| Jeff
|
| "Stefan B Rusynko" wrote:
|
| > Sorry, My error
| > Redo as
| > <%
| > EntryDate = date()
| > If IsDate(request.querystring("Entry_Date")) Then
| > Entry_date = Cdate(request.querystring("Entry_Date"))
| > If EntryDate = Entry_date Then cellcolor= "bgcolor='gray'"
| > Else
| > cellcolor= "bgcolor='FFCC77'"
| > End if
| > %>
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > To find the best Newsgroup for FrontPage support see:
| > http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| > _____________________________________________
| >
| >
| > | Here is what my code looks like now per your suggestion. (I hope this is what
| > | you meant)
| > |
| > | <%
| > | if IsDate request.querystring("Entry_Date") then
| > | Cdate(request.querystring("Entry_Date"))
| > | EntryDate = date()
| > | if EntryDate = (request.querystring("Entry_Date")) then
| > | cellcolor= "bgcolor='gray'"
| > | else
| > | cellcolor= "bgcolor='FFCC77'"
| > | end if
| > | %>
| > |
| > | <td <%=cellcolor%>>
| > |
| > | Now I get this error when I view my asp page:
| > |
| > | Microsoft VBScript compilation error '800a03f9'
| > |
| > | Expected 'Then'
| > |
| > | /allsigninstestbgcolor.asp, line 152
| > |
| > | if IsDate request.querystring("Entry_Date") then
| > | Cdate(request.querystring("Entry_Date"))
| > | ----------^
| > |
| > |
| > | Jeff
| > |
| > |
| > |
| > | "Stefan B Rusynko" wrote:
| > |
| > | > Make sure (request.querystring("Entry_Date")) is a valid date format
| > | >
| > | > Add before
| > | > EntryDate = date()
| > | >
| > | > if IsDate request.querystring("Entry_Date") then Cdate(request.querystring("Entry_Date"))
| > | > --
| > | >
| > | > _____________________________________________
| > | > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > | > "Warning - Using the F1 Key will not break anything!" (-;
| > | > To find the best Newsgroup for FrontPage support see:
| > | > http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| > | > _____________________________________________
| > | >
| > | >
| > | > | Thanks for the response, but no luck. I'm still getting the same results. All
| > | > | of the cells still come up the same color.
| > | > |
| > | > | Jeff
| > | > |
| > | > |
| > | > | "Stefan B Rusynko" wrote:
| > | > |
| > | > | > Try
| > | > | > <%
| > | > | > EntryDate = date()
| > | > | > if EntryDate = (request.querystring("Entry_Date")) then
| > | > | > cellcolor= "bgcolor='gray'"
| > | > | > else
| > | > | > cellcolor= "bgcolor='FFCC77'"
| > | > | > end if
| > | > | > %>
| > | > | >
| > | > | > Then in your table set the cell as
| > | > | > <td <%=cellcolor%>>
| > | > | >
| > | > | > --
| > | > | >
| > | > | > _____________________________________________
| > | > | > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > | > | > "Warning - Using the F1 Key will not break anything!" (-;
| > | > | > To find the best Newsgroup for FrontPage support see:
| > | > | > http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| > | > | > _____________________________________________
| > | > | >
| > | > | >
| > | > | > | Does anyone know how to change the background color in the database results
| > | > | > | table based on the results in a field?
| > | > | > |
| > | > | > | I have a column (on an ASP Intranet Page) that displays the date for each
| > | > | > | item entered into the database.
| > | > | > |
| > | > | > | I would like to change the background color of this column for every day
| > | > | > | except for the current day(today). This is to distinguish todays activity
| > | > | > | from all other days.
| > | > | > |
| > | > | > | I came up with the following code but it's not working correctly. The result
| > | > | > | I get now is the background color is the FFCC77color for all days, including
| > | > | > | today. The gray color will not come up for todays entries.
| > | > | > |
| > | > | > |
| > | > | > | <%
| > | > | > | EntryDate = date()
| > | > | > | if EntryDate = (request.querystring("Entry_Date")) then
| > | > | > | bgcolor="gray"
| > | > | > | else
| > | > | > | bgcolor="FFCC77"
| > | > | > | end if %>
| > | > | > |
| > | > | > |
| > | > | > | Any ideas?
| > | > | > |
| > | > | > | Thanks,
| > | > | > |
| > | > | > | Jeff
| > | > | >
| > | > | >
| > | > | >
| > | >
| > | >
| > | >
| >
| >
| >
 
J

Jeff

I got it to work. I made a few mistakes but now it works exactly as I hoped.
Now I can choose any two colors, or color today's dates and leave the older
dates set to a white background.

Here is the working code in case anyone else ever needs it. (To be posted
directly above the column/s that you want to manipulate within the html)

<%
EntryDate = date()
If IsDate (FP_FieldVal(fp_rs,"Entry_Date")) Then
Entry_date = Cdate(FP_FieldVal(fp_rs,"Entry_Date"))
If CDate(EntryDate) = CDate(Entry_date) Then
cellcolor= "bgcolor='D5EAFF'"
Else
cellcolor= "bgcolor='#FFFFFF'"
End if
End if
%> <td <%=cellcolor%>>


Stephan, thank you for all of your help.

Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top