| Contents > CFML Reference > ColdFusion Functions > IsDefined |
|
|
|
|
||
Evaluates a string value to determine whether the variable named in it exists.
This function is an alternative to the ParameterExists function, which is deprecated.
True, if the variable is found, or, for a structure, if the specified key is defined; False, otherwise.
Returns False for an array or structure element referenced using bracket notation. For example, IsDefined("myArray[3]") always returns False, even if the array element myArray[3] has a value.
IsDefined("variable_name")
ColdFusion MX: Changed behavior: this function can process only the following constructs:
mystruct.key)Parameter |
Description |
|---|---|
variable_name |
String, enclosed in quotation marks. Name of variable to test for. |
When working with scopes that ColdFusion exposes as structures, the StructKeyExists function can sometimes replace this function. The following lines are equivalent:
if(isDefined("form.myVariable"))
if(structKeyExists(form,"myVariable"))
<cfif IsDefined("form.myString")>
<p>The variable form.myString has been defined, so show its contents.
This construction allows us to place a form and its resulting action code
on the same page and use IsDefined to control the flow of execution.</p>
<p>The value of "form.myString" is <b><i>
<cfoutput>#form.myString#</cfoutput></i></b>
<cfelse>
<p>During the first time through this template, the variable "form.myString"
has not yet been defined, so we do not try to evaluate it.
</cfif>
<form action="#CGI.Script_Name" method="POST">
<input type="Text" name="MyString" value="My sample value">
<input type="Submit" name="">
</form>
|
|
||
| Contents > CFML Reference > ColdFusion Functions > IsDefined |
|
|
ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting
Version 6.1
Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/funct130.htm
Comments
Corey Gilmore said on Nov 18, 2003 at 8:11 AM : Corey Gilmore said on Nov 18, 2003 at 12:40 PM : Corey Gilmore said on Feb 6, 2004 at 3:22 PM :