繁体中文
设为首页
加入收藏
当前位置:ASP技术首页 >> ASP基础 >> 控制表格的行列来显示数据

控制表格的行列来显示数据

2005-11-15 08:00:00  作者:  来源:互联网  浏览次数:0  文字大小:【】【】【
简介:很多时候,我们在显示数据库的内容时,会用到几行或几列来显示数据,如10条数据,要以每行2列或3列形式显示。 下面是一个使用数组以表格显示几行几列的简单的示列代码,希望对您有所帮助。 ...
关键字:行列 表格 控制 数据

很多时候,我们在显示数据库的内容时,会用到几行或几列来显示数据,如10条数据,要以每行2列或3列形式显示。

下面是一个使用数组以表格显示几行几列的简单的示列代码,希望对您有所帮助。

<%

function tablebody(arr,cols,functionstr)

'arr为数组

'cols为列数

'functionstr为输出内容用的function,没有为空

dim allnum,i,j

allnum = ubound(arr)

for i = 0 to (allnum/cols)

Response.write (VbTab &"" & VbNewLine)

for j = 0 to (cols-1)

ij = (i*cols+j)

Response.write (VbTab & VbTab &"")

if ij <= allnum then

if len(functionstr) > 0 then

execute(""& functionstr &"(arr(ij))")

else

Response.write (arr(ij))

end if

else

Response.write (" ")

end if

Response.write ("" & VbNewLine)

next

Response.write (VbTab &"" & VbNewLine)

next

end function

function test1(str)

Response.write ("

"& str &"
")

end function

'示例1

dim kk(9)

for k = 0 to 9

kk(k) = k+1

next

%>

<%call tablebody(kk,1,"")%>


<%call tablebody(kk,4,"test1")%>


<%call tablebody(kk,5,"")%>


<%

dim wwwstr,wwwarr

wwwstr = "51windows.Net|blueidea.com|google.com|yahoo.com|msn.com.cn|csdn.net|ipark.cn|1kg.cn"

wwwarr = split(wwwstr,"|")

function urltest1(str)

Response.write (""& str &"")

end function

function urltest2(str)

Response.write ("")

end function

%>

<%call tablebody(wwwarr,3,"urltest1")%>


<%call tablebody(wwwarr,4,"urltest2")%>

转 作者:海娃

责任编辑:admin
相关文章