0
Explorer
,
/t5/coldfusion-discussions/dynamic-variable-inside-cfloop/td-p/160849
Nov 13, 2008
Nov 13, 2008
Copy link to clipboard
Copied
Good day
I have a dynamic form which looks something like this...
<Cfloop from 1 to 6 indes i>
<cfinput type="text" name="description#i#" class="TextBlock">
</cfloop>
When submitting, I want to insert description#i# into a db
At the moment i have this...
<Cfset thedescription = description#i#">
<cfquery name="insertpic" datasource="#application.db#">
INSERT INTO tblpics
(description,)
VALUES ('#thedescription#')
</cfquery>
Its all inisde a loop
How do i set description#i# = somevar?
Please can someone assist?
Regards
Delon
I have a dynamic form which looks something like this...
<Cfloop from 1 to 6 indes i>
<cfinput type="text" name="description#i#" class="TextBlock">
</cfloop>
When submitting, I want to insert description#i# into a db
At the moment i have this...
<Cfset thedescription = description#i#">
<cfquery name="insertpic" datasource="#application.db#">
INSERT INTO tblpics
(description,)
VALUES ('#thedescription#')
</cfquery>
Its all inisde a loop
How do i set description#i# = somevar?
Please can someone assist?
Regards
Delon
TOPICS
Advanced techniques
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
1 Correct answer
Explorer
,
Nov 14, 2008
Nov 14, 2008
Thank you.
Sorted!
Sorted!
Valorous Hero
,
/t5/coldfusion-discussions/dynamic-variable-inside-cfloop/m-p/160850#M14610
Nov 13, 2008
Nov 13, 2008
Copy link to clipboard
Copied
> How do i set description#i# = somevar?
If you are using method="post", form field values are available in the FORM structure. For method="get" they are available in the URL structure. Since they are structures, you can use array notation to extract reference the dynamic field names: #FORM["baseFieldName"& counterVariable]#
<cfloop index="i" ...>
<cfset description = FORM["description"& i]>
...
</cfloop>
Also, consider using cfqueryparam for all query parameters. Especially when looping.
If you are using method="post", form field values are available in the FORM structure. For method="get" they are available in the URL structure. Since they are structures, you can use array notation to extract reference the dynamic field names: #FORM["baseFieldName"& counterVariable]#
<cfloop index="i" ...>
<cfset description = FORM["description"& i]>
...
</cfloop>
Also, consider using cfqueryparam for all query parameters. Especially when looping.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Explorer
,
LATEST
/t5/coldfusion-discussions/dynamic-variable-inside-cfloop/m-p/160851#M14611
Nov 14, 2008
Nov 14, 2008
Copy link to clipboard
Copied
Thank you.
Sorted!
Sorted!
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

