欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

谈动态多行多列,循环行和列,输出M行N列的ASP代码

程序员文章站 2023-01-25 09:18:48
现在感觉真麻烦,下面这样够简单够清楚了吧? 复制代码 代码如下:<%  dim i, j, icols  i&nbs...
现在感觉真麻烦,下面这样够简单够清楚了吧?
复制代码 代码如下:

<% 
dim i, j, icols 
i = 0 '//定义i进行循环 
icols = 3 '//一行有几列(正整数) 
response.write("<table width=""100%"" border=""1"" cellspacing=""2"" cellpadding=""0""><tr>"&vbnewline) '//输出table头和第一个tr 
do while not ors.eof '//开始输出记录集 用 for ors.recordcount next 也行 
    if i>0 and i mod icols = 0 then response.write("</tr><tr>"&vbnewline) '//如果列数等于 icols 换行 
    i = i + 1 
    response.write("<td width="""&formatpercent(1 / icols, 0)&""">输出第 "&i&" 条记录</td>"&vbnewline) 
    ors.movenext 
loop '//结束输出记录集 
ors.close 
for j = 1 to icols -1 '//开始补足空记录,最多补icols-1条 
    if i mod icols = 0 then exit for '//列数已经够 icols 不再输出 
    i = i + 1 
    response.write("<td width="""&formatpercent(1 / icols, 0)&""">补足第 "&j&" 条记录</td>"&vbnewline) 
next 
response.write("</tr></table>"&vbnewline) '//输出table尾 
%>