Re: Loop over field names

2008-07-16 Thread Robert Bell
When submitted, the FORM scope will contain these form fields.

CF can access them using the CFLOOP COLLECTION attribute.

m!ke 

cfoutput
cfloop collection=#FORM# item=blah
   #blah# = #FORM[blah]# br
/cfloop
/cfoutput 

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

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:309172
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Loop over field names

2008-07-16 Thread Brian Kotek
Right but that doesn't help if the field names are username_1, id_1,
username_2, id_2, etc. He needs to be able to organize multiple sets of form
data into the proper format on the server. Simply looping over the form
scope won't help with that. The hard way is to loop over the form data and
try to parse and extract the separate sets of data. The easy way is to use
my Form Utilities component that I mentioned earlier, which will create the
proper data structures automatically.

On Wed, Jul 16, 2008 at 4:44 PM, Robert Bell [EMAIL PROTECTED] wrote:

 When submitted, the FORM scope will contain these form fields.
 
 CF can access them using the CFLOOP COLLECTION attribute.
 
 m!ke

 cfoutput
 cfloop collection=#FORM# item=blah
   #blah# = #FORM[blah]# br
 /cfloop
 /cfoutput

 

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

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:309173
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Loop over field names

2008-07-15 Thread Richard Cooper
Hi All,

Having brain freeze on this... Basically have a form, part of the form is 
populated from a query within an unknown number of field elements.

The form code snippet would look something like this.

cfoutput query=someQuery
  input name=anID#currentRow# value=#anID# /
  input name=someField#currentRow# value=#someFieldValue# /
  input name=otherField#currentRow# value=#otherFieldValue# /
/cfoutput

I want to be able to take the form and run either update or creates for the 
form. How would I go about referencing the form fields to insert/update my DB?

Thanks,

R 

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

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:309044
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


RE: Loop over field names

2008-07-15 Thread Dawson, Michael
When submitted, the FORM scope will contain these form fields.

CF can access them using the CFLOOP COLLECTION attribute.

m!ke 

-Original Message-
From: Richard Cooper [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 15, 2008 6:14 AM
To: CF-Talk
Subject: Loop over field names

Hi All,

Having brain freeze on this... Basically have a form, part of the form
is populated from a query within an unknown number of field elements.

The form code snippet would look something like this.

cfoutput query=someQuery
  input name=anID#currentRow# value=#anID# /
  input name=someField#currentRow# value=#someFieldValue# /
  input name=otherField#currentRow# value=#otherFieldValue# /
/cfoutput

I want to be able to take the form and run either update or creates for
the form. How would I go about referencing the form fields to
insert/update my DB?

Thanks,

R 

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

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:309049
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


RE: Loop over field names

2008-07-15 Thread Adrian Lynch
A few ways, pass the record count along in a hidden field then loop:

cfloop from=1 to=#FORM.recordCount# index=i
cfoutput#FORM[anID  i]#/cfoutput
/cfloop

Or requery on the next page and work out the record count there.

Or do a conditional loop with an IsDefined(FORM.anID#i#) and a counter to
increment i.

A short limerick for you: There once was man name Richard Cooper, who got
WHOOPED on Street Fighter 2

I didn't say it was a good limerick! :O.

-Original Message-
From: Richard Cooper [mailto:[EMAIL PROTECTED]
Sent: 15 July 2008 12:14
To: CF-Talk
Subject: Loop over field names


Hi All,

Having brain freeze on this... Basically have a form, part of the form is
populated from a query within an unknown number of field elements.

The form code snippet would look something like this.

cfoutput query=someQuery
  input name=anID#currentRow# value=#anID# /
  input name=someField#currentRow# value=#someFieldValue# /
  input name=otherField#currentRow# value=#otherFieldValue# /
/cfoutput

I want to be able to take the form and run either update or creates for the
form. How would I go about referencing the form fields to insert/update my
DB?

Thanks,

R


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

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:309056
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


RE: Loop over field names

2008-07-15 Thread Bobby Hartsfield
Use the same query to loop over them again and reference them such as...

cfloop query=someQuery
#form[anID  currentRow]#
#form[someField  currentRow]#
#form[otherField  currentRow]#
/cfloop

-Original Message-
From: Richard Cooper [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 15, 2008 7:14 AM
To: CF-Talk
Subject: Loop over field names

Hi All,

Having brain freeze on this... Basically have a form, part of the form is
populated from a query within an unknown number of field elements.

The form code snippet would look something like this.

cfoutput query=someQuery
  input name=anID#currentRow# value=#anID# /
  input name=someField#currentRow# value=#someFieldValue# /
  input name=otherField#currentRow# value=#otherFieldValue# /
/cfoutput

I want to be able to take the form and run either update or creates for the
form. How would I go about referencing the form fields to insert/update my
DB?

Thanks,

R 



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

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:309122
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Loop over field names

2008-07-15 Thread Brian Kotek
You can also just use my Form Utilities component (
http://formutils.riaforge.org/) to automatically translate array or
structure notation into complex data structures on the server side. So it
would become:

cfoutput query=userQuery
 input name=user[#currentRow#].userID value=#userID# /
 input name=user[#currentRow#].firstName value=#firstName# /
 input name=user[#currentRow#].lastName value=#lastName# /
/cfoutput

And on the server you get back an array of structures. So assuming the query
had 3 rows, you'd get an array named user with three elements. Each
element would be a structure with keys of userID, firstName, and lastName,
with the appropriate values.

It beats the heck out of trying to parse out numbers from field names! :-)


On Tue, Jul 15, 2008 at 7:14 AM, Richard Cooper [EMAIL PROTECTED]
wrote:

 Hi All,

 Having brain freeze on this... Basically have a form, part of the form is
 populated from a query within an unknown number of field elements.

 The form code snippet would look something like this.

 cfoutput query=someQuery
  input name=anID#currentRow# value=#anID# /
  input name=someField#currentRow# value=#someFieldValue# /
  input name=otherField#currentRow# value=#otherFieldValue# /
 /cfoutput

 I want to be able to take the form and run either update or creates for the
 form. How would I go about referencing the form fields to insert/update my
 DB?

 Thanks,

 R

 

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

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:309124
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Loop over field names

2008-07-15 Thread David McCan
Another idea is instead of naming them like you intend with the currentRow:

cfoutput query=someQuery   
   input name=anID#currentRow# value=#anID# /   
   input name=someField#currentRow# value=#someFieldValue# /   
   input name=otherField#currentRow# value=#otherFieldValue# / 
/cfoutput 

Give the form fields that have the same data the same name, removing the 
currentRow appendage:

cfoutput query=someQuery   
   input name=anID value=#anID# /   
   input name=someField value=#someFieldValue# /   
   input name=otherField value=#otherFieldValue# / 
/cfoutput 

In JavaScript these fields that are named the same are treated as an array.  
You can have a hidden form field or write out a JavaScript variable with the 
number of records in the query:

var numberOfRows = #someQuery.recordcount# - 0;  
// - 0 is a trick to indicate variable is numeric

function someFunction()
(
   var row3 = document.myForm.anID[2].value; 
   // JavaScript arrays are 0 based
)

On the server side when the form is submitted, ColdFusion treats these form 
fields that are named the same as a list:

cfset row3 = ListGetAt(anID, 3, ,)

Hope this helps.

Best,

David



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

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:309126
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4