Microsoft KB Archive/825519

= How to use DHTML to add wildcard characters to a database query in FrontPage 2003 =

Article ID: 825519

Article Last Modified on 12/18/2006

-

APPLIES TO


 * Microsoft Office FrontPage 2003

-





For a Microsoft FrontPage 2000 version of this article, see 317924.



For a Microsoft FrontPage 2002 version of this article, see 318435.



IN THIS TASK

 * SUMMARY
 * Step 1 - Prepare to Use the ASP Features in FrontPage
 * Step 2 - Create a Database Results Page
 * Step 3 - Add DHTML to the Page
 * Step 4 - Test the Page
 * REFERENCES



SUMMARY
Use this step-by-step guide to add wildcard characters to a database search form by using Dynamic HTML (DHTML). The example in this article uses a  query and DHTML to create a better version of the built-in  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 may appear as escaped HTML code. 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. Microsoft support professionals 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. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, visit the following Microsoft Web site:

http://www.microsoft.com/partner/referral

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:

http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS

back to top



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 FP2002: What You Need to Use Active Server Pages (ASP) in FrontPage 2002

back to top

Step 2 - Create a Database Results Page

 * 1) In FrontPage 2003, open a Web site on a Web server that supports Microsoft Active Server Pages (ASP).
 * 2) On the Standard toolbar, click the New Page button.
 * 3) Create a Database Results Region.

To do this, point to Database on the Insert menu, and then click Results.
 * 1) Click Use a sample database connection (Northwind), and then click Next.
 * 2) For record source, click the Products table, and then click Next.
 * 3) Click More Options.
 * 4) Click Criteria.
 * 5) Click Add.
 * 6) In the Add Criteria dialog box, set the following options:
 * 7) * Set the field name to ProductName.
 * 8) * Set the comparison to Like.
 * 9) * Use the default, ProductName, for the value.
 * 10) * Click to select the Use this search form field check box if you have to.
 * 11) Click OK to close the Add Criteria dialog box.
 * 12) Click OK to close the Criteria dialog box.
 * 13) Click OK to close the More Options dialog box.
 * 14) Click Next.
 * 15) Click Next.
 * 16) Click Finish.
 * 17) Save the page to your Web and name it ProductName.asp.

back to top

Step 3 - Add DHTML to the Page
 Switch to HTML view.  Add the following DHTML code before the closing  tag:         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; }         Locate and delete the following code: <pre class="fixed_text"><form BOTID=&quot;0&quot; METHOD=&quot;POST&quot; ACTION=&quot;productname.asp&quot;> and replace it with this code: <pre class="fixed_text"><form BOTID=&quot;0&quot; METHOD=&quot;POST&quot; ACTION=&quot;productname.asp&quot; onSubmit=&quot;FixMe(this,this.ProductName)&quot;> </li> Switch back to normal view.</li> Save the page to your Web.</li></ol>

back to top

Step 4 - Test the Page

 * 1) On the Standard toolbar, click the Preview in Browser button.

No form fields should appear on the page.
 * 1) Do not type any text.

Click Submit. The search form field should contain a single percent sign (%) and all the records are returned.
 * 1) 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.

back to top

<div class="references_section">