Arraysum - MACROMEDIA COLDFUSION MX 61-CFML Reference

Cfml reference
Hide thumbs Also See for COLDFUSION MX 61-CFML:
Table of Contents

Advertisement

ArraySum

Description
Array sum function.
Returns
The sum of values in an array. If the
Category
Array
functions,
Function syntax
ArraySum(array)
Parameters
Parameter
array
Example
<h3>ArraySum Example</h3>
<p>This example uses ArraySum to add two numbers together.<br> </p>
<!--- After checking whether the form has been submitted, the code creates
an array and assigns the form fields to the first two elements in
the array. --->
<cfif IsDefined("FORM.submit")>
<cfset myNumberArray = ArrayNew(1)>
<cfset myNumberArray[1] = number1>
<cfset myNumberArray[2] = number2>
<cfif Form.Submit is "Add">
<!--- use ArraySum to add the number in the array --->
<p>The sum of the numbers is
<cfoutput>#ArraySum(myNumberArray)#.</cfoutput>
</cfif>
</cfif>
<!--- This form provides two numeric fields that are added when the form is
submitted. --->
<form action = "arraysum.cfm" method="post">
<input type = "hidden" name = "number1_Float">
<input type = "hidden" name = "number2_Float">
<input type = "text" name = "number1">
<br>
<input type = "text" name = "number2">
<br>
<input type = "submit" name = "submit" value = "Add">
</form>
392
Chapter 3: ColdFusion Functions
array
Mathematical functions
Description
Name of an array
parameter value is an empty array, returns zero.

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion mx

Table of Contents