Using Select Multiple List Boxes in HTML Forms

When an HTML form containing a <SELECT MULTIPLE…> tag is used, Internet Database Connector converts the items selected into a comma-separated list; the list can be used in the .idc file just like other parameters. However, because the parameter is actually a list, it will typically only be used for SQLSelect statements with an IN clause, as in the following examples.

If the parameter name in the .idc file is enclosed in single quotation marks, each element of the list will be enclosed in single quotation marks also. You should enclose the parameter name in single quotation marks whenever the column in the IN clause is a character column or other type in which literals are quoted (dates and times, for example). If there are no single quotation marks around the parameter name, no quotation marks will be placed around each element of the list. You should not enclose the parameter name in single quotation marks when the column in the IN clause is a numeric type or any other type in which literals are not enclosed in single quotation marks.

For example, if an HTML form contained the multiple-choice list box shown below:

<SELECT MULTIPLE NAME="region">
<OPTION VALUE="Western">
<OPTION VALUE="Eastern">
<OPTION VALUE="Northern">
<OPTION VALUE="Southern">
</SELECT>

You can construct an .idc file with an SQL statement:

SQLStatement: SELECT name, region FROM customer WHERE region IN ('%region%')

If the user selected "Northern," "Western," and "Eastern" from the HTML form, the SQL statement would be converted to:

SELECT name, region FROM customer WHERE region IN ('Northern', 'Western', 'Eastern')

Another example of an HTML form is shown below, but this time uses numeric data, and therefore no quotation marks enclose the parameter in the .idc file.

<SELECT MULTIPLE NAME="year">
<OPTION VALUE="1994">
<OPTION VALUE="1995">
<OPTION VALUE="1996">
</SELECT>

You can construct an .idc file with an SQLStatement:

SQLStatement: SELECT product, sales_year FROM sales WHERE sales_year IN (%year%)

If the user selected "1994" and "1995" from the HTML form, the SQL statement would be converted to:

SELECT product, sales_year FROM sales WHERE sales_year IN (1994, 1995)