| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 573 人关注过本帖
标题:如何根据不同的ID把字段里的内容标注不同的颜色
只看楼主 加入收藏
a190066
Rank: 4
等 级:业余侠客
威 望:2
帖 子:175
专家分:204
注 册:2010-6-24
结帖率:79.07%
收藏
已结贴  问题点数:20 回复次数:4 
如何根据不同的ID把字段里的内容标注不同的颜色
如何根据不同的ID把字段里的内容标注不同的颜色

图片附件: 游客没有浏览图片的权限,请 登录注册
搜索更多相关主题的帖子: 字段 颜色 标注 
2010-11-22 18:00
gupiao175
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:40
帖 子:1787
专家分:7527
注 册:2007-6-27
收藏
得分:20 
举个例子:
<%
  sql="select  * from biao1"
 set rs=conn.execute(sql)
while not rs.eof
  select case rs("id")
  case 1
  response.write "<font color=yellow>"&rs("字段1")&rs("字段2")&...&"</font>"
  case 2
  response.write "<font color=red>"&rs("字段1")&rs("字段2")&...&"</font>"
  case 3
  response.write "<font color=purple>"&rs("字段1")&rs("字段2")&...&"</font>"
  case 4
  response.write "<font color=green>"&rs("字段1")&rs("字段2")&...&"</font>"
  case else
  response.write "<font color=white>"&rs("字段1")&rs("字段2")&...&"</font>"
 end select
  rs.movenext   
 wend
%>
这只是一个普通的例子,具体要怎么样,你还可以更改各种形式的。不知道这样说是否能理解!

Q:1428196631,百度:开发地 即可找到我,有事请留言!
2010-11-22 18:57
a190066
Rank: 4
等 级:业余侠客
威 望:2
帖 子:175
专家分:204
注 册:2010-6-24
收藏
得分:0 
谢谢gupiao175!你提供的判断语句我能看得懂但不会运用。用时提示“缺少标识符”
现把代码附上,希望给予帮助:
表:ma2  字段: up1 up2  共有七个ID数。希望每行ID数的内容运用不同的颜色进行标注。(如上图所示)
<!--#include file="conn.asp"--><%
   MaxPerPage=7   
%>
<%
set rs=server.createobject("adodb.recordset")
sql="select * from ma2 order by id asc"
rs.open sql,conn,1,1
%>
<table border="1" width="100%" id="table1">
    <tr>
        <td>ID</td>
        <td align="center">字段1</td>
        <td align="center">字段2</td>
    </tr>
   
<%do while not rs.eof%>

    <tr>
        <td><%=rs("ID")%></td>
        <td align="center"><%=rs("UP1")%></td>
        <td align="center"><%=rs("UP2")%></td>
    </tr>
</table>
2010-11-22 20:45
gupiao175
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:40
帖 子:1787
专家分:7527
注 册:2007-6-27
收藏
得分:0 
<!--#include file="conn.asp"--><%
   MaxPerPage=7   
%>
<%
set rs=server.createobject("adodb.recordset")
sql="select * from ma2 order by id asc"
rs.open sql,conn,1,1
%>
<table border="1" width="100%" id="table1">
    <tr>
        <td>ID</td>
        <td align="center">字段1</td>
        <td align="center">字段2</td>
    </tr>
   
<%do while not rs.eof%>

    <tr>
        <td><%=rs("ID")%></td>
        <td align="center">
        <%
        select case rs("ID")
        case 1
         response.write "<font color=yellow>"&rs("UP1")&"</font>"
        case 2
         response.write "<font color=red>"&rs("UP1")&"</font>"
       case 3
         response.write "<font color=purple>"&rs("UP1")&"</font>"
       case 4
        response.write "<font color=green>"&rs("UP1")&"</font>"
        case else
       response.write "<font color=white>"&rs("UP1")&"</font>"
       end select
        %>
          </td>
        <td align="center">
         <%
        select case rs("ID")
        case 1
         response.write "<font color=yellow>"&rs("UP2")&"</font>"
        case 2
         response.write "<font color=red>"&rs("UP2")&"</font>"
       case 3
         response.write "<font color=purple>"&rs("UP2")&"</font>"
       case 4
        response.write "<font color=green>"&rs("UP2")&"</font>"
        case else
       response.write "<font color=white>"&rs("U2")&"</font>"
       end select
        %>
       </td>
    </tr>
</table>
改成这样拿去测试下。

Q:1428196631,百度:开发地 即可找到我,有事请留言!
2010-11-22 20:55
a190066
Rank: 4
等 级:业余侠客
威 望:2
帖 子:175
专家分:204
注 册:2010-6-24
收藏
得分:0 
成功了。。再次谢谢gupiao175。
2010-11-22 21:24
快速回复:如何根据不同的ID把字段里的内容标注不同的颜色
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.031789 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved