主题:  隔行换色

s22

职务:版主
等级:4
金币:10.0
发贴:1634
注册:2004/12/19 13:06:46
#12003/7/28 14:11:15

SELECT *
FROM Parks











xxx



网络白痴 | 5D荣誉斑竹

职务:普通成员
等级:4
金币:10.0
发贴:1657
注册:2001/1/5 16:32:35
#22003/7/28 14:45:39

s22

职务:版主
等级:4
金币:10.0
发贴:1634
注册:2004/12/19 13:06:46
#32003/7/28 22:42:53
呵呵~我不抛砖就没有人站出来.



Mozier

职务:管理员
等级:5
金币:11.0
发贴:2994
注册:2004/1/12 17:26:30
#42003/7/29 10:32:50
表格颜色的交替实现的方法很多的.



7yue_5d

职务:普通成员
等级:1
金币:0.0
发贴:32
注册:2003/4/1 13:24:33
#52003/7/29 13:12:18
设定两个td的class,不同色彩。比如一个叫td.a,一个叫td.b。
用MOD的方式判断记录集的单双,显示不同的td的class属性,也能搞定。



雅痞公子

职务:普通成员
等级:3
金币:-3.0
发贴:732
注册:2003/3/27 23:16:34
#62003/7/29 22:51:59
One of the most common tasks in ColdFusion programming is to output a simple table of information from a database. What if you have 100 rows to a page and the whole table is a white blur? It makes things hard to read doesn't it? And really, who wants to look at a plain white table when you could jazz it up with some color.

Which would you prefer?

AltaVista www.altavista.com
Google www.google.com
AltaVista www.Webcrawler.com
Excite www.excite.com
MSN www.msn.com


OR

AltaVista www.altavista.com
Google www.google.com
AltaVista www.Webcrawler.com
Excite www.excite.com
MSN www.msn.com


To get this effect, you will need to know 2 basic ColdFusion functions. The MOD operator and the IIF statement.

The MOD operator is a common operator among many languages. It simply takes the remainder of a number after it is divided by a divisor. For example, 18 MOD 5 would equal 3.

The IIF function is very similar to another ColdFusion tag, the CFIF tag. But with an IIF function, we can only have two statements. To use an IIF function we check a condition and if its true we do the first expression and if its false we do the second. See below:

IIf (condition, expression1, expression2)

To change the background color of a row we will place an IIF and a MOD statement in the TR tag. You will also notice the double pound(#) signs. These are required in a CFOUTPUT tag to cancel the other out. If we don't do this, ColdFusion will try to read whatever is between the pound signs and error out in this case.

Our code for alternating rows will look this:









#Engine_Name# #Engine_URL# #Engine_Rank#<



You can download the code for this tutorial by clicking on the links above.



s22

职务:版主
等级:4
金币:10.0
发贴:1634
注册:2004/12/19 13:06:46
#72003/7/31 0:19:58

相关文件:点这儿打开
mxp
哈哈,这个就更方便啦.连代码也省掉了.