|
This worked beautifully! I'm very weak on structures,
but this gave me an opportunity to learn.
BTW, I would have tried it earlier, but our campus got hit
very hard with NIMDA. While our servers have been restored, we still do
not have external Internet access.
Karen R. Harker, MLS
UT Southwestern Medical Library 5323 Harry Hines Blvd. Dallas, TX 75390-9049 214-648-1698 http://www.swmed.edu/library/ >>> [EMAIL PROTECTED] 9/17/01 5:58:49 PM >>> On Mon, Sep 17, 2001 at 05:12:52PM -0500, Karen Harker wrote: > I have a dynamic form with an unknown quantity of radio button fields. It > looks like this: > <CFOUTPUT QUERY="getResources"> > <CFFORM Action="process.cfm" method="post"> > <CFINPUT TYPE="Radio" name="#ResourceID#" Value="Daily" required="yes" > message="Select choice for #resource#"> > <CFINPUT TYPE="Radio" name="#ResourceID#" Value="Weekly" required="yes" > message="Select choice for #resource#"> > <CFINPUT TYPE="Radio" name="#ResourceID#" Value="Occasionally" required="yes" > message="Select choice for #resource#"> > <CFINPUT TYPE="Radio" name="#ResourceID#" Value="Known, not used" required= > "yes" message="Select choice for #resource#"> > <CFINPUT TYPE="Radio" name="#ResourceID#" Value="Not Known" required="yes" > message="Select choice for #resource#"> > </CFFORM> > </CFOUTPUT> > > The form works perfectly, with form fields labled 2, 3, 4, etc. When using the > form with mode=debug, the fields are passed as expected. > ======================================== > > To process this, I thought I would loop through all resourceIDs, using Evaluate > () function, as such: > > <!---query to get all resource IDs---> > <CFQUERY NAME="GetResources" DATASOURCe="DB1"> > SELECT resourceID from Resources > </CFQUERY> > > <CFLOOP LIST="#valueList(GetResources.resourceID#" index="resource"> > <CFSET resourcefield="form."&resource> > <!---This is not the end result; this is a debugging check; I'll want to use > Insert query eventually---> > <CFOUTPUT>Form field: #resourceField# Value: #evaluate('resourcefield')#<BR> > </CFOUTPUT> > </CFLOOP> > I always try to find ways of avoiding the use of the evaluate function because it's confusing and expensive (processing time). Try access the elements of the form as a structure. <CFLOOP LIST="#valueList(GetResources.resourceID#" index="resource"> <CFSET resourcefield = form[resource]> <CFOUTPUT>Form field: #resource# Value: #resourcefield# <BR> </CFOUTPUT> </CFLOOP> That should give you what you are looking for, and run quicker too. -- Josh Meekhof ------------------------------------------------------------------------- This email server is running an evaluation copy of the MailShield anti- spam software. Please contact your email administrator if you have any questions about this message. MailShield product info: www.mailshield.com ----------------------------------------------- To post, send email to [EMAIL PROTECTED] To subscribe / unsubscribe: http://www.dfwcfug.org |
