View Full Version : displaying the values of an array as links
queleanor
06-01-2003, 07:27 AM
Is it possible to set the values of an array (names on a graph) to display as links to other asp pages?
If so, do I code them as I would any link or do I do it when initialising the array?
Appreciate any assistance.
Welcome here.
Im not sure what you're asking for.
Yes, you can dynamically build a set of links through ASP.
How? All links will point to the same (ASP-)page, but will have a variable added in the querystring.
In the (ASP-)page they point to, he value in the querystring is used to perform some actions (like for instance selecting the details of a client or order or whatever --> the clientsID or orderID was then passed on as value in the querystring.)
If you need more info or help on your actual problem, you'll need to give us some more info.
Here's some code for dynamically building links while looping through the recordset;
dim row
row = "0"
do while rsTables.EOF=false
if row MOD 2 = 0 then 'alternating backgroundcolours
response.write("<tr bgcolor='#AAC7FF'>")
else
response.write("<tr bgcolor='#AFEEEE'>")
end if
response.write("<td><a href=admin_defineview.asp?Table=" &rsTables.Fields("TableName") & ">" & server.HTMLEncode (rsTables.Fields("TableName")) &"</a></td>")
response.write("</tr>")
row = row+1
rsTables.MoveNext
loop
On the admin_defineview.asp page, the value in the querystring is used to select the data from the picked table
dim sql
sql="SELECT VariableName, VariableLabel, PK, VarType, VarIndexed, CreateDate, Edit_online FROM Metatable WHERE (((TableName)='thetable') AND ((Display_online)='Yes'))"
sql= replace(sql,"thetable",request.querystring("Table"))
queleanor
06-04-2003, 10:48 AM
Sorry for the delay - I wasn't able to modify your code for my needs. The code below is for the display of a graph. The array values that I want to set as hyperlinks are Title(x) which display horizontally along the bottom of the graph. I want to make each of these values link to their respective information asp pages.
<%
Dim Title(8)
Title(1) = "Multimedia"
Title(2) = "Programming"
Title(3) = "Computer Engineer"
Title(4) = "Networking"
Title(5) = "Business Management"
Title(6) = "Support"
Title(7) = "Education"
Title(8) = "General"
.........
.........
If a = 1 then
HTMLCode = HTMLCode & "<FONT size=1; "
HTMLCode = HTMLCode & "Style=" & chr(34)
HTMLCode = HTMLCode & "position: absolute; "
HTMLCode = HTMLCode & "top: " & (MaxHeight + 15 + TopPadding) & "px; "
HTMLCode = HTMLCode & "left: " & PosLeft & "px;" & chr(34) & ">"
HTMLCode = HTMLCode & Title(x)
HTMLCode = HTMLCode & "</FONT>" & chr(13)
End If
PosLeft = PosLeft + BarPadding
Next
PosLeft = PosLeft - BarPadding
PosLeft = PosLeft + PairPadding
Next
Response.Write HTMLCode
%>
Thank you in advance
Something like
HTMLCode = HTMLCode & "<a href=thepagetolinkto.asp?title=" & x & " title=""Got to " & Title(x) & """>" & Title(x) & "</a>"
This will display a link with the titlevalue. If the link is hit, it will always load thepagetolinkto.asp. In that page, you can grab the x from the querystring with
request.querystring("title")
an perform some action based on that value.
If you want each element in the array to point to a different page, then you'd best include the (relative) fileadress of that page in the array.
queleanor
06-07-2003, 04:47 AM
Thank you again raf - it worked a treat. Very unsure myself so still working on the redirect portion. Will get it because of your assistance. Thanks again for your patience.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.