• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Chapter 15. Web Publishing > Searching for Data with CDML

Searching for Data with CDML

You can create a format file that searches specified fields in the published database, and returns the results in another format file for editing or viewing. For this example, you'll prompt the user to search by last name or state. Users might want to do this if, for example, their contact information has changed and they need to update the information in the database.

To create a search format file:

Open your text editor and follow the instructions in “To create a basic Web page” on page 314.

Follow the instructions in “To create a CDML form header” above to add a CDML form header. Since all of the header information is the same except for the name of the format file that will be used after the search format file, customize the information by entering a new file name in the format line (Figure 15.41):

<INPUT TYPE="hidden" NAME="-format" VALUE="findedit.htm">

Figure 15.41. “findedit.htm” will be the format file that the search format file calls.

Position your cursor just before the </FORM> close tag and insert a line of HTML text prompting the visitor to locate his or her name in the records (Figure 15.42):

<P>Please find your name.</P><P></P>

Figure 15.42. You can insert HTML text inside a </FORM> tag.

Next we'll add the code that prompts the user for the Find criteria. Right after the prompt line you just created and above the </FORM> close tag (Figure 15.43), add these lines of code:

<P><SELECT NAME="-op"> 
   <OPTION>not equals
   <OPTION>begins with
   <OPTION>ends with
Last Name: <INPUT TYPE="text" NAME="LastName" VALUE="" SIZE=20></P>

Figure 15.43. The <SELECT> HTML code creates a pop-up list of the options within it.

The SELECT NAME=“-op” creates a pop-up list that allows the user to choose a find operator from the options that you specify with the <OPTION> tag.

By duplicating and editing the code, you allow a search by State as well as by Last Name. Copy the code from step 4 above and paste it in below the existing lines. Change Last Name to State and NAME=“LastName” to NAME=“State” (Figure 15.44).

Figure 15.44. Always duplicate and edit code rather than retyping it.

Add this line below the second block of code:

<P><INPUT TYPE="submit" NAME="-find" VALUE="Find">

The Submit button code contains the action tag “-find”, which tells FileMaker to search for the data entered in the fields and display the results in the findedit.htm file from the format tag in the header.

Add this line below the submit line (Figure 15.45):

<P><INPUT TYPE="reset" VALUE="Clear Form">

Figure 15.45. Once a search has finished, clearing the form allows a second search to be done.

This input command clears the form fields of all previous data. It's the last line we add within the <FORM> tags.

Save the file to your Web folder. In this example, we've named it webfind.htm.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint