Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hyperlink sub-categories

Status
Not open for further replies.

gav12345

Programmer
Dec 4, 2003
198
GB
Hi all,

I am being a bit lazy asking this, but time is short so I'd appreciate some help (also quite new to this so it may be quite an obvious one).

I have a web page comprising 3 asp pages, corresponding to 3 frames. The user selects a system in the left 'SystemList.asp' frame, which displays a list of reports in the main 'MainFrame.asp' page. The top frame just displays the heading etc. Application is connecting to a simple Access database with tables for 'Reports', 'Subsystems', and 'Systems'.

I currently have a list of three hyperlinks in the SystemList frame. Depending on which System you click, you will get a different set of reports in the MainFrame page. The code for this is currently:

Code:
<%
On Error Resume Next
Dim con2
Dim prm
dim link(10)

Set con2 = CreateObject("ADODB.Connection")
con2.Open "CentralReporting"

Set cmdSys = CreateObject("ADODB.Command")
Set cmdSys.ActiveConnection = con2
cmdSys.CommandText = "Select SystemName from System"
Set rsSys = cmdSys.Execute()
 
dim iCount
dim iCount2
iCount = 0
iCount2 = 0

for iCount = 1 to 10 
	link(iCount) = "<tr align=left><td valign = top width =2><img src = " & chr(34) & _
	"images/orange dot.bmp" & chr(34) & "></td><td valign = middle align=left><a href=" & _
	chr(34) & "MainFrame.asp?System=" & rsSys("SystemName") & chr(34) & "target=" & chr(34) & _
	"mainframe" & chr(34) & "><h5>" & rsSys("SystemName") & "</h5></a></td>"
	rsSys.movenext
	//rs2.movenext
next

response.write("<table>")

for iCount2 = 1 to 10
	response.write (link(iCount2))
next

response.write("</table>")

con2.close

%>

I've been asked to add sub-categories to each System. I.e., the user will select a system, which will display (in a smaller font) a list of 3 or 4 sub-categories beneath it (from the Subsystems table), in the left SystemList frame. The user would then select one of those, and the mainframe reports would be displayed accordingly.......SO, the question is, how do I change the hyperlinks I have defined, so that instead of passed the System name to the MainFrame page, it instead displays a list of subsystems, which the user can then click on to display relevent reports in the Mainframe page?

Thanks in advance, Gavin
 
I don't follow the logic...

Do you want the ASP to produce different HTML based on the URL?

If so then the ASP should examine values from the [red]QueryString[/red] and apply some sort of IF/THEN or SELECT/CASE decision logic.


TIP: The code above assumes the database table will always have 10 rows. A better way to loop through rows in a recordset is as follows:[tt]
response.write "<table>"
Do While Not rsSys.EoF
response.write "<tr align=left><td valign = top width =2>"
response.write "<img src = " & chr(34) & "images/orange dot.bmp" & chr(34)
response.write "></td><td valign = middle align=left><a href=" & chr(34)
response.write "MainFrame.asp?System=" & rsSys("SystemName") & chr(34)
response.write "target=" & chr(34) & "mainframe" & chr(34)
response.write "><h5>" & rsSys("SystemName") & "</h5></a></td>"

rsSys.movenext
Loop
response.write "</table>"
[/tt]


This is better than the array approach because it will not raise an error if there are fewer than 10 rows in the database table and it will create HTML output for all rows even if there are more than 10.
 
Thanks Sheco - I've been off for a couple of days, I'm going to have a look at this tomorrow & will let you know how it goes. Gavin
 
Hi Sheco - I'm afraid I wasn't very clear in my own head what I was asking, but have resolved my initial query. - I have taken your advice on the '10 rows' issue, so many thanks for the time you spent with that.

Gavin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top