Adobe ColdFusion 8

Using number signs in ColdFusion tag attribute values

You can put variables, functions, or expressions inside tag attributes by enclosing the variable or expression with number signs. For example, if the variable CookieValue has the value "MyCookie", the following line sets the cfcookie value attribute to "The value is MyCookie":

<cfcookie name="TestCookie" value="The value is #CookieValue#">

You can optionally omit quotation marks around variables used as attribute values as shown in the following example:

<cfcookie name = TestCookie value = #CookieValue#>

However, surrounding all attribute values in quotation marks is more consistent with HTML coding style.

If you use string expressions to construct an attribute value, as shown in the following example, the strings inside the expression use single quotation marks (') to differentiate the quotation marks from the quotation marks that surround the attribute value.

<cfcookie name="TestCookie2" value="The #CookieValue & 'ate the cookie!'#">

Note: You do not need to use number signs when you use the cfset tag to assign one variable's value to another value. For example, the following tag assigns the value of the oldVar variable to the new variable, newVar: <cfset newVar = oldVar>.