Adding costs in cfloop
i am trying to create a simple invoicing script for a friend. I can get the loop to add another row and save the data. My propblem is when I try to add up the material costs. I keep getting the followinf error: Element cost1 is undefined in a Java object of type class coldfusion.filter.FormScope. (line 121)
<!--- Gets the value of getnumba from above --->
<input type="hidden" name="numba" value="#getnumba#">
<!--- Loop Through from 1 to the number above --->
<cfloop from="1" to="#getnumba#" index="idx">
<!--- At first, it displays the original one row form --->
<!--- User enters the data and hits "Add Another" --->
<!--- The page reloads with the data already entered and creates a new blank row that is ready for data entry --->
<tr>
<cfif isdefined ("form.partno#idx#")>
<Td><input type="text" name="partno#idx#" value="#evaluate("form.partno#idx#")#" size="62"></TD>
<cfelse>
<Td><cfinput type="text" name="partno#idx#" size="62"></TD>
</cfif>
<cfif isdefined ("form.cost#idx#")>
<Td><cfinput type="text" name="cost#idx#" value="#evaluate("form.cost#idx#")#" size="6"></TD>
<cfelse>
<Td><cfinput type="text" name="cost#idx#" size="6"></TD>
</cfif>
</tr>
</cfloop>
<tr>
<td align="right">Materials Total </td>
<td>
<cfset subcost = 0>
<cfloop from="1" to="#getnumba#" index="idx">
<cfset subcost = variables.subcost + form["cost" & idx]> (line 121)
</cfloop>
#subcost#
</td>
</tr>
What am I doing wrong?
