WebSTAR 4 Manual & Technical Reference

Manual Contents | Chapter Contents | Previous Page | Next Page

Creating a Search Form

Now that you have an overview of what LDML is, we're going to step through the creation of a form that will search the included CDs.fp3 database.

Required Tags for a Search

When creating a web page that can be used to search your web enabled database, you must use certain action and command tags. Our example database will be the CDs.fp3 database that can be found in the Tools & Examples folder.

Search Example

Below is an example form with the minimum tags required for performing a search. Each line of the form is discussed in detail.

 

<form method="post" action="action.lasso">
 
	<input type="hidden" name="-Database" value="CDs.fp3">
 
	<input type="hidden" name="-Layout" value="Web">
 
	<input type="hidden" name="-Response" value="hitlist.html">
 
		Artist: <input type="text" name="Artist"><br>
 
		Title: <input type="text" name="Title"><br>
 
	<input type="submit" name="-Search" value="Search">
 
</form>

Line 1:

<form method="post" action="action.lasso">
This is a standard HTML form tag. The important part for this discussion is the action attribute, action="action.lasso". When you installed WebSTAR Lasso Publisher, it automatically installed Action and Suffix Map entries within WebSTAR to redirect "action.lasso" forms and URLs to Lasso.

Line 2:

<input type="hidden" name="-Database" value="CDs.fp3">
This command tag tells Lasso that the information contained in this form is intended for the CDs.fp3 database.

Line 3:

<input type="hidden" name="-Layout" value="Web">
Similar to the above command tag, you must tell Lasso which database layout to access.

Line 4:

<input type="hidden" name="-Response" value="hitlist.html">
This command specifies which page is to be returned when the search is completed. If the file is in the same folder as the form page you're working on, you only need to enter the file name. If the file is in any other folder, you'll need to use standard HTML paths (see Example Hierarchy and File Paths ).
For hitlist.html , see Displaying Search Results .

Lines 5 and 6:

Artist: <input type="text" name="Artist">
Title: <input type="text" name="Title">
These are standard text input fields. It is important to put the exact name of the field you wish to search on in the name attribute.

Line 7:

<input type="submit" name="-Search" value="Search">
Now that you've told Lasso which database and layout to use, what page to return with the results, and which fields to search on, the -Search action tells Lasso to perform the find. Whatever text you place in the value attribute will become the Submit button's text.

Line 8:

</form>
Standard HTML, this tag closes the form.

Other Important Tags

Before deploying a search page, there are some tags that should be included in your form even though they are not strictly necessary.

-AnyError

The -AnyError tag tells Lasso which page to return in the event of an error. In a form, it looks like this:

 

	<input type="hidden" name="-AnyError" value="error.html">

When Lasso encounters an error, it returns the error.html document instead of the document specified in the -Response command.

-NoResultsError

Sometimes a user will perform a search that yields no matches in the database. Lasso allows you to return a special page when these circumstances occur.

 

<input type="hidden" name="-NoResultsError" value="noresults.html">

In the above example, when a search has no results, Lasso returns the noresults.html document. You can put a search form, along with useful hints and tips on this page.

If they are on the same page, -AnyError always takes precedence over -NoResultsError, and -NoResultsError is ingnored.

-MaxRecords

This command specifies how many records will be displayed on the response page. For example, if your search results in 30 matches, you may want to show the matches ten at a time. Setting the -MaxRecords to 10 tells Lasso you only want to see your results ten at a time.

Users of your site may appreciate the ability to choose their own value for this feature. Below is the HTML you would use to give them a pop-up list.

 

<p>Show me 
 
<select name="-MaxRecords">
 
<option value=5>5
 
<option value=10>10
 
<option value=15>15
 
<option value=20>20
 
</select>
 
results per page.</p>
 

Search Operators

Operators (sometimes called Boolean Operators ) are commands for searching. You can specify how search terms should be interpreted by FileMaker on the back end, to define which records from the database match the search.

For example, say you've typed Bass into the Artist field of the search form and Hits into the Title field. If you are doing a logical AND search, the database will only return records that contain both Bass in the Artist field and Hits in the Title field. If you do a logical OR search, the database will return every record with either Bass in the Artist field or Hits in the Title field.

Because our CDs.fp3 database has one record each for "Bass Man Floyd, Rock Bottom Hits " and "The Vallejo Lifestyle, Super Hits of the 70s " the AND search would only return the "Bass Man Floyd" record, while the OR search would return both of them, because they both have the word "HITS" in the title.

-LogicalOperator

In Lasso, the command to tell the server what you want is -LogicalOperator , which can have a value of and or or . In the example code below, it is controlled by a set of radio buttons:

 

<input type="radio" name="-LogicalOperator" value="and">And 
 
<input type="radio" name="-LogicalOperator" value="or">Or<br>
 


Manual Contents | Chapter Contents | Previous Page | Next Page