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!

Active state?

Status
Not open for further replies.

Beat

Technical User
Aug 26, 2001
41
0
0
SE
Hi,
I am building dynamic websites for my clients that allows them to update content and add pages to their websites themselves. One of the features I have is dynamic navigation that allows them to add/edit and remove menu items.

I almost always use a rollover state in the menu, but I have never been able to add an active state to it, that will highlight what page the visitor is on. And since it is a dynamic website that just refreshes the page with another record when you go to another page I havent been able to use the active state in CSS.

Can anyone help me out here?

Many thanks!

 
Dynamic menu and pages.

Each record has a unique id.
assign a page variable equal to the record unique id
in the navigation menu assign the id to another variable
then just check to see if the are equal and set the class as active if it is or inactive if not.
Something like:
Code:
page recordset code
SELECT * FROM tblWhatever WHERE fldID = urlParameter
navigation recordset
SELECT fldID,fldPageName FROM tblWhatever
assign the page variable
<%varID = rsPage.Fields.Item("fldID").Value%>
now just compare this to the navigation record as you build the repeat region
  <% 
While ((Repeat1__numRows <> 0) AND (NOT rsNavigation.EOF)) 
%>
<% 
varNavID = rsNav.Fields.Item("fldID").Value 
if varNavID = varID varClass="active"
else varClass="inactive"
%>
<td class="<%=varClass%>">menu content here
<% 
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  rsNavigation.MoveNext()
Wend
%>
I have just thrown this together without checking anything so you will probably have to tweek things, but it should give you the general picture

Cheech

[Peace][Pipe]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top