webformselection
OPTIONS

The webformselection statement selects data based on input from a web form. The web form must have fields that match the database fields.


Parameters

This statement has one parameter:

options – one or more option=value pairs that control how the data is processed. See the text below for a detailed description of the available options.


Description

This statement selects data based on input from a web form. The web form must have fields that match the database fields. Alternately, if the web form has a field named SearchAllFields then the options parameter is ignored and all fields will be searched and any matches selected. Either way, when this statement is finished the global variable cgiSelectedRecordCount contains the number of records that match the formula.

The web form must be set up with a submit action that will trigger a procedure that contains a webformselection statement. This statement processes the fields submitted from the form and scans the database to find records that match the submitted data. In it’s simplest form the webformselection statement can be used with no options at all, like this code, which displays the selected records in a table (see htmldatatable for more information on formatting data in an HTML table).

webformselection {}
htmldatatable myTableOptions

By default the webformselection statement takes each entered item and checks for records that contain that text. If more than one item is entered then only records that contain both will be selected. If a field is numeric then = is used instead of contains. For example if the price specified is 9 then only prices that are exactly 9.00 will match, not 99, 19 or 0.9, even though they contain the 9 digit.

WebFormSelection Options

The webformselection statement has one parameter, a list of options that customize the way the statement looks for matching records. In the simple example above there were no options specified at all — the example simply used the default behavior of the webformselection statement. Add one or more of the options listed below to customize the selection.

do=statement

This option controls the statement used to find or select data. There are seven choices:

The default if no option is specified is select. Use selectwithin or selectadditional if you want to combine the new selection with a previous selection in the same procedure. The findbackwards option search the database from the bottom to the top, instead of top to bottom. If the search order is important, make sure the database is sorted the way you want before using webformselection. The options ending with all first select all records, then perform the find or findbackwards operation.

multiple=and/or

This option controls how multiple fields will be combined in the selection formula. The default is and.

compare=operator

This option specifies the comparison operator that will be used in the selection for- mula. Any Panorama comparison operator can be used, including =, <, >, [≤][], <=, [≥][], [=>][], [≠][], <>, contains, match, regexmatch, beginswith, endswith, and soundslike . The default is contains.

For numeric or date fields, only the =, <, >, [≤][], <=, [≥][], [=>][], [≠][] and <> operators are legal. If you specify one of the other operators, = will be used for any numeric or date fields. By the way, Panorama’s Smart Date™ feature will work with any date fields, so the user can enter dates like today or next tuesday.


To illustrate these options, suppose a user submitted a search form with the values LastName=rea and State=ca. With no options specified the webformselection statement will select all records where the last name contains wilson and the state contains CA. The contains operator is case insentive, so this search will match names like Rea and Reagan in California.

If a compare option is added like this:

webformselection {compare="="}

the statement will select all records where the last name equals wilson and the state equals CA. Since probably there is no one named rea (all lower case), this search will probably turn up nothing. A better search would be to use the match operator, which will match anyone named Rea, but not Reagan.

webformselection {compare="match"}

The multiple= option controls how multiple items interact. Here’s a modified procedure that uses or instead of and.

webformselection {multiple="or"}

This statement will select all records where the last name contains rea OR the state contains CA. In other words, everyone named Rea or Reagan, but also everyone in California no matter what their name is.

Searching All Fields

If the webformselection statement detects a field named SearchAllFields in the submitted data it works differently. In that case it ignores any other fields on the form and only processes the SearchAllFields field. It searches the database looking for any records that contain the contents of the SearchAllFields field in any database field. So for example if the user typed in John, it would match someone with a first or last name of John, or a last name of Johnson, or in the city of Johnsonville, etc.

If you want to restrict this search to only specific fields instead of all fields, use the searchfields option. This option requires a list of the fields you want to search, comma separated.

webformselection {searchfields="First,Last"}

With this code, if the user typed in John, it would match someone with a first or last name of John, or a last name of Johnson, but not in the city of Johnsonville.


See Also


History

VersionStatusNotes
10.2No ChangeCarried over from Panorama 6.0, but now uses the searchfield= option to restrict the scope of an "all fields" search, instead of the (nonexistant) Live Clairvoyance wizard.