談動態多行多列,迴圈行和列,輸出M行N列的ASP代碼_應用技巧

來源:互聯網
上載者:User
現在感覺真麻煩,下面這樣夠簡單夠清楚了吧?
複製代碼 代碼如下:

<% 
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尾 
%> 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.