Conditional cell shading of table in classic asp page

I have an ASP page that displays data pulled from an excel sheet with a named range called "tblData" in the cell of the table where I have a percentage number I want to make it to where if the number is between 1 and 5 then the cell is green. if the umber is between 6 and 8 its yellow, then if its over 8 its red. this is what I have now:

<%
If rs.Fields("2017 Rate") >= 1 OR rs.Fields("2017 Rate") <= 5 then
	Response.Write "<td bgcolor='green' style='width: 301px; height: 21px;' class='auto-style3'>"
Elseif rs.Fields("2017 Rate") >= 6 OR rs.Fields("2017 Rate") <= 8 then
	Response.Write "<td bgcolor='yellow' style'width: 301px; height: 21px;' class='auto-style3'>"
Elseif rs.Fields("2017 Rate") >= 8 then
    Response.Write "<td bgcolor='red' style'width: 301px; height: 21px;' class='auto-style3'>"
End If
%>
<strong>
<%=rs.fields("2017 Rate")%>
</strong></td>

Open in new window


and it just colors all the cells in that column green regardless of the number.
jlcannonAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Big MontyWeb Ninja at largeCommented:
You'll need to convert the database to a numeric value, then do your check. You also need to use the AND clause in your IF statementsI've rewritten your code to be a bit more simple:

<%
dim rate : rate = CInt( rs.Fields("2017 Rate") )
color = "red"    '-- color for when rate > 8

If rate >= 1 AND rate <= 5 then
	color = "green"
Elseif rate >= 6 AND rate <= 8 then
	color = "yellow"
end if
Response.Write "<td bgcolor='" & color & "' style'width: 301px; height: 21px;' class='auto-style3'>"
%>
<strong>
<%=rate%>
</strong></td>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jlcannonAuthor Commented:
excellent, thank you this worked perfectly.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.