Chapter 2: ColdFusion Functions
255
ArrayAvg
Returns the average of the values in the specified array.
Syntax
ArrayAvg
(
array)
array
Name of the array containing values you want to average.
Example
<!--- This example shows the use of ArrayAvg --->
<!---------------------------------------------------------------------
This following six lines of code keep track of the form fields that can
be dynamically generated on the screen. It uses the Fieldnames variable
with the ListLen function to determine the number of fields on the form.
----------------------------------------------------------------------->
<CFSET FormElem = 2>
<CFIF Isdefined("Form.Submit")>
<CFIF Form.Submit is "More">
<CFSET FormElem = ListLen(Form.Fieldnames)>
</CFIF>
</CFIF>
<HTML>
<HEAD>
<TITLE>ArrayAvg Example</TITLE>
</HEAD>
<BODY>
<H3>ArrayAvg Example</H3>
<P>
This example uses ArrayAvg to find the average of the numbers that you
enter into an array.<BR>
If you would like to enter more than two numbers press the <b>more</b>
button.
</P>
<FORM ACTION="arrayavg.cfm" METHOD="post">
<!---------------------------------------------------------------------
The following code initially creates two fields and then adds fields
if the user presses the MORE button. Note that FormElem is initialized to
two at the beginning of this code to indicate that the form has two
fields.
----------------------------------------------------------------------->
<INPUT TYPE="submit" NAME="submit" VALUE="more">
<table cellspacing="2" cellpadding="2" border="0">
<CFLOOP index="LoopItem" from="1" to="#FormElem#">
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...