周韶宁,vxmba,唐长红
很多时候,我们在显示的内容时,会用到几行或几列来显示数据,如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 &"<tr>" & vbnewline)
for j = 0 to (cols-1)
ij = (i*cols+j)
response.write (vbtab & vbtab &"<td width="""& formatnumber(100/cols,0) &"%"">")
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 ("</td>" & vbnewline)
next
response.write (vbtab &"</tr>" & vbnewline)
next
end function
function test1(str)
response.write ("<p align=""center"">"& str &"</p>")
end function
示例1
dim kk(9)
for k = 0 to 9
kk(k) = k+1
next
%>
<table border="1" width="600" cellpadding="2">
<êll tablebody(kk,1,"")%>
</table>
<hr>
<table border="1" width="600" cellpadding="2">
<êll tablebody(kk,4,"test1")%>
</table>
<hr>
<table border="1" width="600" cellpadding="2">
<êll tablebody(kk,5,"")%>
</table>
<hr>
<%
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 ("<a href=""https://www."& str &""" target=""_blank"">"& str &"</a>")
end function
function urltest2(str)
response.write ("<button style=""width:100%;"" onclick=""window.open("& str &",,)"">"& str &"</button>")
end function
%>
<table border="1" width="480" cellpadding="2">
<êll tablebody(wwwarr,3,"urltest1")%>
</table>
<hr>
<table border="2" width="480" cellpadding="2" cellspacing="2" >
<êll tablebody(wwwarr,4,"urltest2")%>
</table>
转 作者:海娃
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Net Core Web Api项目与在NginX下发布的方法
asp.net core3.1 引用的元包dll版本兼容性问题解决方案
IdentityServer4实现.Net Core API接口权限认证(快速入门)
ASP.NET Core MVC通过IViewLocationExpander扩展视图搜索路径的实现
网友评论