The ASP controls the columns of the table to display the data

Source: Internet
Author: User
Control | data | Show a lot of times, when we display the contents of a database, we use a few rows or columns to display the data, such as 10 pieces of data, to be displayed in 2 or 3 columns per row.

Here is a simple listing code that uses an array to display a few rows of columns in a table, in the hope of helping you.

<%
function Tablebody (ARR,COLS,FUNCTIONSTR)
' Arr array
' Cols is the number of columns
' Functionstr function for output content, not NULL

 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 ("<div align=" "Center" ">" & str & "</div>")
End Function


' Example 1
Dim kk (9)
For k = 0 to 9
KK (k) = K+1
Next
%>
<table border= "1" width= "cellpadding=" 2 ">
<%call tablebody (kk,1, "")%>
</table>

<table border= "1" width= "cellpadding=" 2 ">
<%call tablebody (kk,4, "test1")%>
</table>

<table border= "1" width= "cellpadding=" 2 ">
<%call tablebody (kk,5, "")%>
</table>

<%
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=" "http://www.") & Str & "" "target=" "_blank" ">" & str & "</a>"
End Function

function Urltest2 (str)
Response.Write ("<button style=" "width:100%;" "onclick=" "window.open" (' http://www. " & Str & "', ', '" "" > "& str &" </button> ")
End Function
%>
<table border= "1" width= "cellpadding=" "2" >
<%call tablebody (wwwarr,3, "Urltest1")%>
</table>

<table border= "2" width= "cellpadding=" 2 "cellspacing=" 2 ">
<%call tablebody (wwwarr,4, "Urltest2")%>
</table>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.