asp 中如何根据不同条件显示不同字体颜色

来源:百度知道 编辑:UC知道 时间:2024/05/07 04:31:52
<td>
<%
set rs0=server.CreateObject("ADODB.RecordSet")
sql0="select * from params where type='"&rs("hezhun")&"' and name='hezhun'"
rs0.open sql0,conn,1,3
if not rs0.eof then
hz=rs0("note")
else hz=""
end if
rs0.close
set rs0=nothing
%>
<%=hz%>
</td>
我想显示的值(hz)是“同意”字体为绿色、“不同意”用红色、“暂缓”用蓝色,怎么写呢。

我的写法是把
“<%=hz%>
</td>”
写成如下:可是好像没有效果

<%if trim(hz)="同意" then %>
<font color="#990000">
<%=hz%></font>
<%end if %>
<%=hz%>
</td>
谢谢“飞上枝头当乌鸦”的回答。
可是不知道为什么,我页面上字无论它是“同意”还是“不同意”,显示都是蓝色,绿色和红色都显示不出。
这是怎么回事?

将<%=hz%> 直接改写成如下代码:
<%
Select Case hz
Case "同意"
Response.Write "<font color='green'>"
Case "不同意"
Response.Write "<font color='red'>"
Case "暂绶"
Response.Write "<font color='blue'>"
End Select
Response.Write hz&"</font>"
%>

<%
select case hz
case "同意": Color="green"
case "不同意": color="red"
case else
color="blue"
end select
%>
<font color="<%=color%>"><%=hz%></font>