Ben,
FORM.FIELDNAMES is a handy object sometimes. However, I find that
occasionally I prefer to loop through my own list(s) to do some specific
processing. The methodology I use follows (roughly, based upon the scant
information you provided):
1. I would imagine that you already get the product_name (or primary key, or
something to identify your products) as the result set of a query and loop
through that list to display the product_name as a static label on the first
form, correct?
2. After running the query, turn the product_name result set into a list and
make sure it is sent to the processing template via CLIENT, SESSION, HIDDEN,
or URL scope: <CFQUERY>qry_getProductName</CFQUERY><CFSET product_list =
ValueList(qr_getProductName.product_ID)> (or cost, or whatever other field
you might need to use later)
3. Also in the first form, name all the edit boxes where the user enters a
quantity the same name: qty_ordered (or whatever). These fields will
automatically be sent to the processing template as a comma-delimited list
named qty_ordered (2,10,1,4, etc.).
4. On the processing form, loop through the product list, displaying the
value of each product/qty as the output:
First template:
<CFQUERY NAME="qry_getProductName" DATASOURCE="your_DSN">
<!--- get your product list --->
</CFQUERY>
<CFSET product_list = ValueList(qry_getProductName.product_name)>
<!--- Loop through the above query to display your products and have a text
box ALL named "qty_ordered" (name of your choice). The latter set of text
boxes (qty_ordered) will automatically forward to the next template as a
comma-delimited list. --->
<!--- In the form somewhere, before the closing </FORM>, send your
product_list to the processing template --->
<INPUT TYPE="Hidden" NAME="product_list">
**********************************************************************
Processing form:
Loop through both lists for display and further processing:
<CFLOOP FROM="1" TO="#ListLen(product_list)#" INDEX="VARIABLES.i">
<CFIF qty_ordered NEQ "0">
<CFOUTPUT>
Product Name: #ListGetAt(product_list, VARIABLES.i)#<BR>
Quantity Ordered: #ListGetAt(#qty_ordered, VARIABLES.i)#
</CFOUTPUT>
</CFIF>
<CFLOOP>
Obviously this is only one possible scenario of how this type of thing can
be handled, and not necessarily the most elegant or fastest (processor
wise). In addition, it can be expanded in any number of useful ways. This
methodology can also tend to get a little hard to follow if using too many
lists--I generally only use it for two or three lists at a time. Beyond that
I use structures, arrays or wddx, whichever seems to fit the occasion best.
You might wish to look into ARRAY, STRUCTURE and WDDX processing for future
use in cases such as this.
Hope something here helps!
Cheers,
--
David L. Rice
Web Applications Developer
Nation Tax, Inc.
www.nationtax.com
[EMAIL PROTECTED]
Direct: 205.380.8164
--------------------------
-----Original Message-----
From: Ben Densmore [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 31, 2000 8:30 AM
To: [EMAIL PROTECTED]
Subject: Getting a value from a field
This is a multi-part message in MIME format.
------=_NextPart_000_0044_01C0132D.F7ADEA40
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
can someone tell me if there is a way to get values out of a form, =
similar to using form.fieldname? Ihave a page where I have about 50 =
products each with their own text box to enter a quantity. Once a person =
submits the form I want to loop through it and if the particular item =
doesn't have a 0 for a value then i want to display that item that was =
ordered. any help would be appreciated.
Thanks
Ben Densmore
------=_NextPart_000_0044_01C0132D.F7ADEA40
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4134.600" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>can someone tell me if there is a way =
to get values=20
out of a form, similar to using form.fieldname? Ihave a page where I =
have about=20
50 products each with their own text box to enter a quantity. Once a =
person=20
submits the form I want to loop through it and if the particular item =
doesn't=20
have a 0 for a value then i want to display that item that was ordered. =
any help=20
would be appreciated.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanks</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Ben Densmore</FONT></DIV></BODY></HTML>
------=_NextPart_000_0044_01C0132D.F7ADEA40--
----------------------------------------------------------------------------
--
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.