Chapter 2: ColdFusion Functions
515
SetVariable
The function sets the variable specified by name to value and returns the new value of
the variable.
See also
DeleteClientVariable
and
GetClientVariablesList
.
Syntax
SetVariable
(
name, value)
name
Valid variable name.
value
String or number assigned to the variable.
Usage
When setting client variables, it is required that the client variable exists prior to the
using of this function and the ClientManagement attribute of CFAPPLICATION tag has
been set to "Yes" for this template.
Examples
<!--- This example shows SetVariable --->
<HTML>
<HEAD>
<TITLE>
SetVariable Example
</TITLE>
</HEAD>
<BODY BGCOLOR=silver>
<H3>SetVariable Example</H3>
<CFIF IsDefined("FORM.myVariable")>
<!--- strip out url, client., cgi., session., caller. --->
<!--- This example only lets you set form variables --->
<CFSET myName = ReplaceList(FORM.myVariable,
"url,client,cgi,session,caller", "FORM,FORM,FORM,FORM,FORM")>
<CFSET temp = SetVariable(myName, FORM.myValue)>
<CFSET varName = myName>
<CFSET varNameValue = Evaluate(myName)>
<CFOUTPUT>
<P>Your variable, #varName#
<P>The value of #varName# is #varNameValue#
</CFOUTPUT>
</CFIF>
...
Summary of Contents for COLDFUSION 4.5-CFML LANGUAGE
Page 1: ...Allaire Corporation CFML Language Reference ColdFusion 4 5...
Page 207: ...Chapter 1 ColdFusion Tags 183 CFCATCH CFTRY BODY HTML...
Page 224: ...200 CFMLLanguageReference CFOUTPUT P Text within CFOUTPUT is always shown CFOUTPUT BODY HTML...
Page 336: ...312 CFMLLanguageReference CFIF BODY HTML...
Page 404: ...380 CFMLLanguageReference DE It is morning CFOUTPUT P BODY HTML...
Page 413: ...Chapter 2 ColdFusion Functions 389 Customer BalanceDue BR CFOUTPUT CFIF BODY HTML...
Page 483: ...Chapter 2 ColdFusion Functions 459 CFOUTPUT CFLOOP BODY HTML...
Page 584: ...560 CFMLLanguageReference...
Page 594: ...570 CFMLLanguageReference...