I need help in correcting the following code.
To be more specific, i have created the form page with simple html and added "field1#CurrentRow#" to the name
<input type="Text" name="field1#CurrentRow#" size="8" maxlength="20">
and the action page looks the following. But it doesnt work.
<CFQUERY NAME="GetWoord" datasource="mydsn" dbtype="ODBC">
SELECT *
FROM table
</CFQUERY>
<!--- Declare variable rec to sort and get the last record count --->
<cfset rec = Listlast(listsort(valuelist(GetWoord.id), "numeric", "asc"
)>
<!--- Run loop: one for every row outputed earlier --->
<cfloop index="i" from="#rec#" to="#form.RecordCount#">
<cfset locfield1 = "form.field1" & i>
<cfset locfield2 = "form.field2" & i>
<cfset locfield3 = "form.field3" & i>
<cfset locfield4 = "form.field4" & i>
..
<!--- All dynamic form variables are evaluated here . --->
<cfquery name="getwoord#i#" datasource="mydsn">
INSERT INTO table
(field1, field2, field3, field4,... )
VALUES
('#Evaluate(locfield1)#', '#Evaluate(locfield2)#', '#Evaluate(locfield3)#',...)
</cfquery>
<!--- Loop to next row --->
</cfloop>
<!--- use CFLOCATION to return to mainform.cfm --->
<CFLOCATION URL="mainform.cfm" addtoken="No">
To be more specific, i have created the form page with simple html and added "field1#CurrentRow#" to the name
<input type="Text" name="field1#CurrentRow#" size="8" maxlength="20">
and the action page looks the following. But it doesnt work.
<CFQUERY NAME="GetWoord" datasource="mydsn" dbtype="ODBC">
SELECT *
FROM table
</CFQUERY>
<!--- Declare variable rec to sort and get the last record count --->
<cfset rec = Listlast(listsort(valuelist(GetWoord.id), "numeric", "asc"
<!--- Run loop: one for every row outputed earlier --->
<cfloop index="i" from="#rec#" to="#form.RecordCount#">
<cfset locfield1 = "form.field1" & i>
<cfset locfield2 = "form.field2" & i>
<cfset locfield3 = "form.field3" & i>
<cfset locfield4 = "form.field4" & i>
..
<!--- All dynamic form variables are evaluated here . --->
<cfquery name="getwoord#i#" datasource="mydsn">
INSERT INTO table
(field1, field2, field3, field4,... )
VALUES
('#Evaluate(locfield1)#', '#Evaluate(locfield2)#', '#Evaluate(locfield3)#',...)
</cfquery>
<!--- Loop to next row --->
</cfloop>
<!--- use CFLOCATION to return to mainform.cfm --->
<CFLOCATION URL="mainform.cfm" addtoken="No">