试试看下面的代码,因为随机概率的缘故,不是很平均
程序代码:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.>
<html xmlns="http://www.>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
.blue { color:#0000FF; }
.blueB { color:#0000FF; font-weight:bold; }
.red { color:#FF0000; }
.redB { color:#FF0000; font-weight:bold; }
.green { color:#009900; }
.greenB { color:#009900; font-weight:bold; }
-->
</style>
</head>
<body>
<%
classArray = array("blue","blueB","red","redB","green","greenB") '样式数组
dim dataArray(11) '数据数组(供演示用,你可以从数据库中取)
dataArray(0) = "aaaaaaaaaa"
dataArray(1) = "bbbbbbbbb"
dataArray(2) = "cccccccccc"
dataArray(3) = "dddddddddd"
dataArray(4) = "eeeeeeee"
dataArray(5) = "fffffffffff"
dataArray(6) = "gggggggggggggg"
dataArray(7) = "hhhhhhhhhhhh"
dataArray(8) = "iiiiiiiiiii"
dataArray(9) = "jjjjjjjjjjjj"
dataArray(10) = "kkkkkkkkk"
dataArray(11) = "zzzzzzzzzzzz"
for i=0 to ubound(dataArray)
Randomize
k = int(100*Rnd)
if k<25 then '这里25%的概率
Randomize
c = int((ubound(classArray)+1)*Rnd) '随机class
Response.Write("<div class="""&classArray(c)&""">"&dataArray(i)&"</div>")
else
Response.Write("<div>"&dataArray(i)&"</div>")
end if
next
%>
</body>
</html>