Sets the variable specified by name to value; returns the new value of the variable.
SetVariable(name, value)
DeleteClientVariable, GetClientVariablesList
| Parameter |
Description |
|---|---|
| name |
Variable name |
| value |
String or number assigned to the variable |
The client variable must exist before using this function. The ClientManagement attribute of cfapplication tag must have been set to "Yes" for this template.
|
Note If you concatenate string elements to form the name parameter, you can improve performance using CFSET instead. |
<cfset "myVar#i#" = myVal>
SetVariable("myVar" & i, myVal)
<!--- 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>
...