cfscript

Description

Encloses a code segment containing cfscript.

Category

Web application framework tags

Syntax


<cfscript> 

 cfscript code goes here 

</cfscript> 

See also

cfapplication, cflock, cfassociate, cfmodule, cfauthenticate, cfimpersonate

Usage

Use cfscript to perform processing in cfscript instead of CFML. Note the following:

One use of cfscript is to wrap a series of assignment functions that would otherwise require cfset statements.


Note

If you use cfscript around the cfloop tag, any test expressions used as values to cfloop attributes are re-evaluated before each iteration of the loop, and if any part of the test expression is changed by code in the loop, it may affect the number of iterations that are executed by the loop.


For more information, see Developing ColdFusion Applications.

Example

<!--- This example shows the use of cfscript --->

<html>

<head>

<title>cfscript Example</title>

</head>



<body bgcolor = silver>

<H3>cfscript Example</H3>



<P>cfscript adds a simple scripting language to ColdFusion

for those developers who are more comfortable with JavaScript 

or VBScript syntax.



<P>This simple example shows variable declaration and manipulation.

<cfif IsDefined("form.myValue")>

<cfif IsNumeric(form.myValue)>

<cfset x = form.myValue>



<cfscript>

y = x;

z = 2 * y;

StringVar = form.myString;

</cfscript>



<cfoutput>

<P>twice #x# is #z#.

<P>Your string value was: <B><I>#StringVar#</I></B>

</cfoutput>

<cfelse>

...



Banner.Novgorod.Ru