This article describes how to dynamically create a table of contents with Active Server Pages (ASP) for use with the Database Results Wizard.
NOTE: This article uses custom Dynamic Hypertext Markup Language (DHTML) and cascading style sheets (CSS) that may not be available in all browsers.
For more information about this topic, click
Microsoft FrontPage Help on the
Help menu, type
compatibility in the Answer Wizard, and then click
Search to view the topic.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
NOTE: You may receive an error message if you copy the examples directly from this article and paste them into FrontPage. The angle brackets (< and >) may appear as escaped HTML code (< and >). To work around this behavior, paste the script into a blank Notepad document, and then copy it from Notepad before you paste it into FrontPage.
Table of Contents Example
The following steps demonstrate how to create a dynamic table of contents for the Database Results Wizard to use.
- Open a Web site on a Microsoft Internet Information Services-based Web server.
- Start a new page, and switch to HTML view.
- Remove all the existing HTML, and type the following code:
<html>
<head>
<!-- this is a style sheet used for DHTML hover effects on the buttons -->
<style>
.normal { BACKGROUND-COLOR: #cccccc; COLOR: #000000 }
.hover { BACKGROUND-COLOR: #0000ff; COLOR: #ffffff }
.current { BACKGROUND-COLOR: #ff0000; COLOR: #ffffff }
</style>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<%
' declare variables
Dim X, strClass
' loop through the letters A-Z
For X = 0 To 26
' output the starting TD & FORM tags
Response.Write "<td><form action="""
Response.Write Request.ServerVariables("URL")
Response.Write """ method=""POST"">"
' find the current button
If (Request("CustomerID") = Chr(X+64)) Or (Len(Request("CustomerID"))=0 And X=0) Then
strClass = "current"
Else
strClass = "normal"
End If
' output the search buttons
Response.Write "<input type=""submit"" value="""
If X > 0 Then
Response.Write Chr(X+64) & """ style=""width:20"" name=""CustomerID"""
Else
Response.Write "ALL"" style=""width:40"""
End If
Response.Write " class=""" & strClass
Response.Write """ onMouseover=""this.className='hover'"""
Response.Write " onMouseout=""this.className='" & strClass & "'"">"
' output the closing FORM & TD tags
Response.Write "</form></td>" & vbCrLf
' end the loop
Next
%>
</tr>
</table>
</body>
</html>
- Switch back to normal view.
- On the Insert menu, click Database and then click Results.
- Select Sample Database Connection (Northwind), and then click Next.
- Select Customers as the record source, and then click Next.
- Click the More Options button.
- Click the Criteria button.
- Click the Add button.
- Select CustomerID for the Field Name.
- Select Begins With for the Comparison.
- Click OK three times.
- Click Next twice.
- Clear the Add search form check box.
- Click Finish.
- Save the page as dbtoc.asp in your Web site.
- Click Preview in Browser on the standard toolbar in FrontPage.
When a user browses this page by using HTTP, the page displays a table of contents, followed by the output of the FrontPage Database Results Wizard. When a user clicks a button in the table of contents, the database is filtered for data that begins with the letter that is clicked.