Author |
Topic  |
|
Lycaster
New Member

USA
60 Posts |
Posted - 07 June 2001 : 12:36:33
|
I was hoping someone could help me with an Array. I am working with someone else’s code. I am kind of new to ASP so this might be a "Newbie" question.
Okay here is what I am doing.
I a list of navigation links that dynamically pull from the database. The code I have now displays these links like this:
About Us Ad Banners Alerts Business News Calendar Contact Us Daily Tip Division Admins Divisions Encarta Encyclopedia FAQ From CEO Investor Relations Job Postings Links Media Library Media Stats Module Status MSN Search Nasdaq Stock Newsletter Outlook Inbox Partners Policies Poll Poll Results Products Staff Directory Stock Quotes Subscribe Test Log Testimonials Weather
What I need to do is have this Array split into 2 table columns. So half way down it automatically dumps the rest of the content into another table column to the right.
Here is my code:
<%@ LANGUAGE="VBSCRIPT" %> <!-- #include file="common/Security.asp" --> <!-- #include Virtual="/AuthoringCenter/Common/ContentPublish.asp" --> <!-- #include file="common/navitems.asp" --> <% ' Local Variables Dim sStream ' HTML Stream Dim aLinks ' Array of links Dim oHTML ' HTML Text Stream Generator Dim Conn ' Data source Connection Dim rs ' Data source Recordset Dim sSelect ' SQL select statement Dim i ' Array index ' Create HTML Stream Generator Set oHTML = Server.CreateObject("KIHTML2.KIHTMLStream") ' Create data source connection Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open Application.Value("DSN") ' Get Updateable Section records sSelect = "SELECT TypeName, UpdSectTypeGUID FROM UpdSectTypes WHERE SiteGUID = '" & Application.Value("WACSiteGUID") sSelect = sSelect & "' ORDER BY TypeName ASC" set rs = Conn.Execute(sSelect) ' If some Updateable Sections where found ReDim aLinks(40) i = 0 While Not rs.EOF ' Create links aLinks(i) = CreateLink(rs("TypeName"), "SiteContent/UpdSectionView.asp?UpdSectTypeGUID=" & rs("UpdSectTypeGUID"), "d_main") i = i + 1 rs.MoveNext Wend ReDim Preserve aLinks(i - 1) ' Create Nav with links sStream = oHTML.HorzontalNavBar(aLinks, "3", "0", "left")
Function CreateLink( Contents, HREF, Target) ' Local Variables Dim sStream ' HTML Stream ' Create request link sStream = oHTML.Font(CStr(Contents), Application("NavFont"), 1) sStream = oHTML.Anchor(CStr(sStream), CStr(HREF), CStr(Target)) CreateLink = sStream End Function ' Check for wac links Dim avNames ' WACLinkName array Dim avLinks ' WACLink array Dim avTargets ' WACLink array Dim sWACLink ' Display sWACLink = "" If Trim(Application.Value("WACLinkName")) <> "" Then avNames = Split(Application.Value("WACLinkName"), ", ") avLinks = Split(Application.Value("WACLink"), ", ") If Trim(Application.Value("WACTarget")) <> "" Then avTargets = Split(Application.Value("WACTarget"), ", ") End if For i = LBound(avNames) To UBound(avNames) 'if target is specified point the link to the appropriate target window If IsArray (avTargets) Then If avTargets(i) <> "''" Then sTemp = oHTML.Anchor(avNames(i), avLinks(i), avTargets(i)) 'if no target specified then use d_main as the default target window End If Else sTemp = oHTML.Anchor(avNames(i), avLinks(i), "d_main") End if sTemp = oHTML.Font(sTemp, "arial", "1") sTemp = oHTML.Column(sTemp, "", "", "Right") sWACLink = sWACLink & oHTML.Row(sTemp) Next sWACLink = oHTML.Table(sWACLink, "", "0", "6", "0") End If
%> <html> <style type="text/css"> <!-- a { text-decoration: none} a:hover { color: #CC0000} --> </style> <head> <title>Web Authoring Center</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body leftmargin="0" rightmargin="0" marginheight="0" marginwidth="0" topmargin="0" link="<%=Application("NavFontColor")%>" vlink="<%=Application("NavFontColor")%>" bgcolor="#FFFFFF"> <table border=0 cellpadding=0 cellspacing=0 width=88%> <tr> <td> </td> </tr> <tr> <td><table cellpadding="6" cellspacing="0" align="left"> <tr> <td><font face="arial" size="1"><a href="/" target="_top">Home</a></font></td> </tr> </table></td> </tr> <tr> <td><%=sStream%></td> </tr> <% If Trim(ExtraLink) <> "" Then %> <tr> <td><% =ExtraLink %></td> </tr> <% End If %> <% If Trim(sWACLink) <> "" Then %> <tr> <td align="right"><% =sWACLink %></td> </tr> <% End If %> </table> </body> </html>
If anyone could help I would be so thankful.
Jared
|
|
K
Starting Member
14 Posts |
Posted - 08 June 2001 : 11:03:04
|
I don't quite follow all your code, but from reading at the top what you are trying to do, couldn't you maybe do something like building the table row, and the first column (<tr><td>) and then looping through the array from 0 to ubound(array)/2 (half of the array) and then close the cell and open a new one for the second column (</td><td>) and loop through the second half of the array from ubound(array)/2 + 1 to ubound(array) then finally close off the column and row (</td></tr>).
Sorry if I've misunderstood!
|
 |
|
|
Topic  |
|
|
|