FrontPage 2003 How To
Please Note:
FrontPage 2003 is no longer supported for Fpweb.net managed hosting clients. However, we continue to offer online help & support resources for Microsoft® FrontPage in our expansive Support Achive.
How to Use DHTML to Add Wildcard Characters to a Database Query in FrontPage 2003
Use this step-by-step guide to add wildcard characters to a database search form by using Dynamic HTML (DHTML).
IN THIS TASK
SUMMARY
The example in this article uses a <Like> query and DHTML to create a better version of the built-in <Contains> query.
Note: This article uses custom DHTML that may not be available in all browsers. For more information about compatibility with other browsers, click Microsoft® FrontPage Help on the Help menu, type compatibility in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
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.
Microsoft® provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability, fitness, or both for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and the tools that are used to create and to debug procedures.
MORE INFORMATION
Step 1 – Prepare to Use the ASP Features in FrontPage
Before you can use the ASP features in FrontPage 2003, install the components that are listed in the following Microsoft® Knowledge Base article:
318287 FP: What You Need to Use Active Server Pages
Step 2 – Create a Database Results Page
- In FrontPage 2003, open a Website on a Web server that supports Microsoft® Active Server Pages (ASP).
- On the Standard toolbar, click the New Page button.
- Create a Database Results Region.
To do this, point to Database on the Insert menu, and then click Results. - Click Use a sample database connection (Northwind), and then click Next.
- For record source, click the Products table, and then click Next.
- Click More Options.
- Click Criteria.
- Click Add.
- In the Add Criteria dialog box, set the following options:
- Set the field name to ProductName.
- Set the comparison to Like.
- Use the default, ProductName, for the value.
- Click to select the Use this search form field check box if you have to.
- Click OK to close the Add Criteria dialog box.
- Click OK to close the Criteria dialog box.
- Click OK to close the More Options dialog box.
- Click Next.
- Click Next.
- Click Finish.
- Save the page to your Web and name it ProductName.asp.
Step 3 – Add DHTML to the Page
- Switch to HTML view.
- Add the following DHTML code before the closing:
</head> tag:
<script language="javascript">
function FixMe(tmpForm,tmpField)
var strTemp = tmpField.value.toString();
if (strTemp.substring(0,1) != '%')
strTemp = '%' + strTemp;
if (strTemp.substring(strTemp.length-1,strTemp.length) != '%')
strTemp = strTemp + '%';
tmpField.value = strTemp;
tmpForm.submit();
}
</script> - Locate and delete the following code:
<form BOTID="0" METHOD="POST" ACTION="productname.asp">and replace it with this code (put on one line):
<form BOTID="0" METHOD="POST" ACTION="productname.asp" onSubmit="FixMe(this,this.ProductName)"> - Switch back to normal view.
- Save the page to your Web.
Step 4 – Test the Page
-
On the Standard toolbar, click the Preview in Browser button.
No form fields should appear on the page.
-
Do not type any text.
Click Submit. The search form field should contain a single percent sign (%) and all the records are returned.
-
Clear the input field on the search form, type Bob’s, and then click Submit.
%Bob’s% appears in the input field and all the fields that contain that text string are displayed.
REFERENCES
For additional information about errors that can appear when working with the Database Results Region, click the following article numbers to view the articles in the Microsoft® Knowledge Base:
265320 – FP2000: Error Message When You Query the Database
299911 – FP2002: Error Message Appears in Database
287147 – FP: Error Message: "Database Results Error"
317931 – FP: Error 0x80040E14 When Using a Database
The information in this article applies to:
- Microsoft® Office FrontPage 2003
Microsoft® Knowledge Base Article – 825519
Enjoy hassle-free, expert dedicated hosting services from Fpweb.net.