256
<tr>
</tr>
</CFLOOP>
</table>
<INPUT TYPE="submit" NAME="submit" VALUE="get the average">
</FORM>
<!--- create an array --->
<CFIF IsDefined("FORM.submit")>
<CFSET myNumberArray = ArrayNew(1)>
<CFSET Count = 1>
<CFLOOP index="ListItem" list="#Form.Fieldnames#">
</CFLOOP>
<CFIF Form.Submit is "get the average">
<CFELSE>
values.</CFOUTPUT>
</CFIF>
</CFIF>
</BODY>
</HTML>
<CFOUTPUT>
<th align="left">Number #LoopItem#</th>
<td><INPUT TYPE="text" NAME="number#LoopItem#"></td>
</CFOUTPUT>
<CFIF Left(ListItem,3) is "Num">
<CFSET myNumberArray[Count] = Val(Evaluate("number#Count#"))>
<CFSET count = IncrementValue(Count)>
</CFIF>
<!--- use ArrayAvg to get the average of the two numbers --->
<P>The average of the numbers that you entered is
<CFOUTPUT>#ArrayAvg(myNumberArray)#.</CFOUTPUT>
<CFOUTPUT>Try again. You must enter at least two numeric
CFML Language Reference
Need help?
Do you have a question about the COLDFUSION 4.5-CFML LANGUAGE and is the answer not in the manual?
Questions and answers