循环遍历两个不同的html表

时间:2014-07-22 15:52:58

标签: asp-classic

我正在寻找一整天的答案。

基本上,我在getrows()

中有两个html表和一个记录集

页面的设计使得有两个html表,我需要生成它,没有其他选择来重新设计页面:(

这是html表。它们是水平对齐的。

table1                table2
row                   row
row                   row
row                   row

依旧...... 如何生成这些表,当然我不知道记录集中有多少条记录。

假设有3个字段,名称,数量和日期。所以,将有两个html表,我得到六列,每个表三个。我不会将不同的字段分配给不同的表。所以表格是相同的,并排,不同的数据,而不是字段

1 个答案:

答案 0 :(得分:0)

您可以创建一个"容器表"这将有两个并排的桌子,以便他们按照你的愿望布局。你没有指定,所以我有表1的前半部分数据,表2有后半部分。 (它更容易/更简单,但你只需要花费一点额外的努力来完成表1中的第1行,表2中的第2行,表1中的第3行,表2中的第4行等等。 。)

因此,从通过GetRows获得的记录数组开始(在我的示例中为arrData),并假设您的数组按顺序(从左到右)显示它们,您希望它们显示出来:

Response.Write "<table><tr><td>"
dim intLastRow
intLastRow = ubound(arrData, 2)
dim intBreakPoint
intBreakPoint = fix(intLastRow/2)
dim intSecondStartPoint = intBreakPoint + 1
Response.Write "<table>"
dim i
for i = 0 to intBreakPoint
    Response.Write "<tr><td>" & arrData(0, i) & "</td><td>" & arrData(1, i) & "</td><td>" & arrData(2, i) & "</td></tr>"
next
Response.Write "</table>"
if intLastRow > 0 then
    Response.Write "<table>"
    for i = intSecondStartPoint to intLastRow
        Response.Write "<tr><td>" & arrData(0, i) & "</td><td>" & arrData(1, i) & "</td><td>" & arrData(2, i) & "</td></tr>"
    next
    Response.Write "</table>"
end if
Response.Write "</td></tr></table>"