基于DB值的文本颜色 [英] Text Color Based on DB Value

查看:142
本文介绍了基于DB值的文本颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Dreamweaver制作ASP页面。我从ASP页面上显示的MSSQL数据库中有一个数据表

。我希望能够根据MSSQL数据库中的优先级数字(数据来自的相同记录集)更改颜色。我

页面上没有优先级字段,但如果需要

,可以将其删除。我有3个不同的优先级数字,如果第一行是

优先级1我希望字体为红色,如果第二行是优先级

2我希望颜色为是黄色等等。


谢谢


克里斯

I am using dreamweaver to make an ASP page. I have a table of data
from a MSSQL database that is currently showing on the ASP page. I
want the ability to change the color based on a priority number that''s
in the MSSQL database (same recordset that the data comes from). I
don''t have the priority field out on the page but can put it out if
need be. I have 3 different priority numbers and if the first row is
priority 1 I want the font to be red and if the second row is priority
2 I want the color to be yellow and so on.

Thanks

Chris

推荐答案

col = rs(" priority")

如果col = 1则

fontcolor ="#FF0000"

elseif col = 2然后

fontcolor =" #FFFF00"

结束如果

response.write"< span style = '' 颜色:" &安培; fontcolor& ">" &安培;东西& "< / span>"


" Chris Stanley" < CH ********** @ gmail.com>在消息中写道

news:11 ********************** @ g47g2000cwa.googlegr oups.com ...
col = rs("priority")
if col = 1 then
fontcolor = "#FF0000"
elseif col = 2 then
fontcolor = "#FFFF00"
end if
response.write "<span style=''color:" & fontcolor & "''>" & stuff & "</span>"

"Chris Stanley" <ch**********@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
我使用Dreamweaver制作ASP页面。我有一个数据表来自MSSQL数据库,该数据库当前显示在ASP页面上。我希望能够根据MSSQL数据库中的优先级数字(数据来自的相同记录集)更改颜色。我没有在页面上显示优先级字段,但如果需要,可以将其删除。我有3个不同的优先级数字,如果第一行是
优先级1我希望字体为红色,如果第二行是优先级
2我希望颜色为黄色,依此类推。

谢谢

Chris
I am using dreamweaver to make an ASP page. I have a table of data
from a MSSQL database that is currently showing on the ASP page. I
want the ability to change the color based on a priority number that''s
in the MSSQL database (same recordset that the data comes from). I
don''t have the priority field out on the page but can put it out if
need be. I have 3 different priority numbers and if the first row is
priority 1 I want the font to be red and if the second row is priority
2 I want the color to be yellow and so on.

Thanks

Chris



感谢您的快速回复。我需要放置一个地方

这段代码???


克里斯

Thanks for the quick response. Is there a certain place I need to put
this code???

Chris



" Chris Stanley" < CH ********** @ gmail.com>在消息中写道

news:11 ********************** @ g47g2000cwa.googlegr oups.com ...

"Chris Stanley" <ch**********@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
我使用Dreamweaver制作ASP页面。


8 |

我有一个数据表来自MSSQL数据库,该数据库当前显示在ASP页面上。我希望能够根据MSSQL数据库中的优先级数字(数据来自的相同记录集)更改颜色。我没有在页面上显示优先级字段,但如果需要,可以将其删除。我有3个不同的优先级数字,如果第一行是
优先级1我希望字体为红色,如果第二行是优先级
2我希望颜色为黄色等等。
I am using dreamweaver to make an ASP page.
8|
I have a table of data
from a MSSQL database that is currently showing on the ASP page. I
want the ability to change the color based on a priority number that''s
in the MSSQL database (same recordset that the data comes from). I
don''t have the priority field out on the page but can put it out if
need be. I have 3 different priority numbers and if the first row is
priority 1 I want the font to be red and if the second row is priority
2 I want the color to be yellow and so on.



您可以使用CSS类名中的优先级编号,如下所示:

< style type =" text / css">

tr.priority1 {background-color:#ff0000; }

tr.priority2 {background-color:#ffff00; }

tr.priorityAndSoOn {background-color:#AndSoOn; }

< / style>

<%

请勿使用你的RSS.EOF

sPriority = yourRS .Fields.Item(" Priority")。Value& "")

%>

< tr class =" priority<%= sPriority%>">

< td><%= yourRS.Fields.Item(" something")。Value%>< / td>

...

< ; / tr>

<%

yourRS.MoveNext

Loop

%>


雷在工作



You could use the priority number in your CSS class name like so:
<style type="text/css">
tr.priority1 { background-color: #ff0000; }
tr.priority2 { background-color: #ffff00; }
tr.priorityAndSoOn { background-color: #AndSoOn; }
</style>
<%
Do While Not yourRS.EOF
sPriority = yourRS.Fields.Item("Priority").Value & "")
%>
<tr class="priority<%=sPriority%>">
<td><%=yourRS.Fields.Item("something").Value%></td>
...
</tr>
<%
yourRS.MoveNext
Loop
%>

Ray at work




这篇关于基于DB值的文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆