I wrote a CFC a while back that takes form field names that use array or
structure syntax and converts them into actual arrays and structures on the
CF side (to any arbitrary level of nesting). It's handy not only for dynamic
fields (no more trying to parse user_1, user_2, etc.) but also for building
whatever collections of data you want (i.e. let it build up a user structure
and pass that into your model rather than doing it manually, or passing the
whole form scope, etc.)
http://formutils.riaforge.org/index.cfm

http://www.briankotek.com/blog/index.cfm/2007/9/4/Implicit-Creation-of-Arrays-and-Structures-from-Form-Fields

On Fri, Dec 19, 2008 at 3:09 PM, Aaron Rouse <aaron.ro...@gmail.com> wrote:

> I always pass a hidden form element that is a counter filled in by JS for
> how many fields have been added.  So if I have a field named foo_1 and I
> add
> foo_2, foo3, foo_4 and take away even foo_2 my hidden counter will pass in
> 4.  then on the processing side I do a loop over my counter, something
> like:
>
> <cfloop from="1" to="#Form.Counter#" index="i">
> <cfif StructKeyExists(FORM, "foo_#i#") AND Trim(Form["Foo_#i#"]) IS NOT
> "">Then do something</cfif>
> </cfloop>
>
> On Fri, Dec 19, 2008 at 2:02 PM, Judah McAuley <ju...@wiredotter.com>
> wrote:
>
> > The way I do this is to have each form field have an underscore in it.
> > So play_1, play_2, etc
> >
> > Then I'd loop over the FORM collection and do a listfirst with _ as a
> > delimiter to figure out if I've got a play, a po, a role, etc or some
> > random field (like submit) that I don't care about. Then append the
> > value of form.play_1 to my playarray and move on to the next item in
> > the form collection.
> >
> > Judah
> >
> > On Fri, Dec 19, 2008 at 11:57 AM, Scott Stewart <saste...@email.unc.edu>
> > wrote:
> > > Hey all,
> > >
> > > I have a form with one of those wonderful dynamic "ad form row"
> widgets.
> > > Because of this I never will know exactly what fields will be sent for
> > > processing...
> > >
> > > the original four fields in the row are called "play", "po", "role",
> and
> > > "year", the javascript generates "play1", "po1", "role1" and "year1" or
> > > 2, or 3 ad Infinitum based on how many rows the user has selected.
> > > on the processing side I need to write the form field values to a
> > > structure because there will be credit card processing before I write
> to
> > > the database.
> > >
> > > How can I loop over the form structure and find the dynamically
> > > generated form fields and their values.
> > >
> > > --
> > > Scott Stewart
> > > ColdFusion Developer
> > >
> > > Office of Research Information Systems
> > > Research &amp; Economic Development
> > > University of North Carolina at Chapel Hill
> > >
> > > Phone:(919)843-2408
> > > Fax: (919)962-3600
> > > Email: saste...@email.unc.edu
> > >
> > >
> > >
> > >
> >
> >
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317000
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to