![MACROMEDIA COLDFUSION 4.5-DEVELOPING WEB Скачать руководство пользователя страница 77](http://html1.mh-extra.com/html/macromedia/coldfusion-4-5-developing-web/coldfusion-4-5-developing-web_develop-manual_3286369077.webp)
Chapter 5: Making Variables Dynamic
51
<OPTION VALUE="’Sales’">Sales
</SELECT>
<INPUT TYPE="hidden"
NAME="SelectDepts_required"
VALUE="You must select at least one department.">
If the user selected the Marketing and Sales items, the value of the SelectDepts form
field would be ’Marketing’,’Sales’.
Just as you did when using checkboxes to search database fields containing string
values, use the ColdFusion PreserveSingleQuotes function with multiple select boxes:
SELECT *
FROM Departments
WHERE DepartmentName IN (#PreserveSingleQuotes(form.SelectDepts)#)
The statement sent to the database would be:
SELECT *
FROM Departments
WHERE DepartmentName IN (’Marketing’, ’Sales’)
Testing for a variable’s existence
Before relying on a variable’s existence in an application page, you can test to see if it
exists using the IsDefined function. For example, the following code checks to see if a
Form variable named Order_ID exists:
<CFIF Not IsDefined("FORM.Order_ID")>
<CFLOCATION URL="previous_page.cfm">
</CFIF>
The argument passed to the IsDefined function must always be enclosed in double
quotes. See the CFML Language Reference for more information on the IsDefined
function.
If you attempt to evaluate a variable that has not been defined, ColdFusion will not be
able to process the page. To help diagnose such problems, use the interactive debugger
in ColdFusion Studio or turn debugging on in the ColdFusion Administrator. The
Administrator debugging information shows which variables are being passed to your
application pages.
Creating Default Variables with CFPARAM
Another way to create a variable is to test for its existence and optionally supply a
default value if the variable does not already exist. The following shows the syntax of
the CFPARAM tag:
<CFPARAM NAME="
VariableName
"
TYPE="
data_type
"
DEFAULT="
DefaultValue
">
Содержание COLDFUSION 4.5-DEVELOPING WEB
Страница 1: ...Allaire Corporation Developing Web Applications with ColdFusion ColdFusion 4 5...
Страница 14: ...xiv Developing Web Applications with ColdFusion...
Страница 26: ...xxvi Developing Web Applications with ColdFusion...
Страница 34: ...8 Developing Web Applications with ColdFusion...
Страница 70: ...44 Developing Web Applications with ColdFusion...
Страница 84: ...58 Developing Web Applications with ColdFusion...
Страница 114: ...88 Developing Web Applications with ColdFusion...
Страница 148: ...122 Developing Web Applications with ColdFusion...
Страница 174: ...148 Developing Web Applications with ColdFusion...
Страница 208: ...182 Developing Web Applications with ColdFusion...
Страница 244: ...218 Developing Web Applications with ColdFusion...
Страница 274: ...248 Developing Web Applications with ColdFusion...
Страница 288: ...262 Developing Web Applications with ColdFusion...
Страница 300: ...274 Developing Web Applications with ColdFusion...
Страница 350: ...324 Developing Web Applications with ColdFusion...
Страница 362: ...336 Developing Web Applications with ColdFusion...