How about --

<cfloop from="1" to="#form.looplength#" index="i">
<cfoutput>

<!--- concatenate the 2 values --->
<cfset temp1 = "form.cat_id" & #i#>
<!--- then evaluate the concatenated expression --->
<cfset catarray[i] = evaluate(temp1)>

<cfset temp2 = "form.subcat_id" & #i#>
<cfset subcatarray[i] = evaluate(temp2)>

<etc.>


I got something similar to work for me just today, though I wasn't using
arrays.

~~~~~~~~~~~~~~~~~~~~~~~~
Ricq Pattay <[EMAIL PROTECTED]>
Univ of MN College of Veterinary Medicine


----- Original Message -----
From: Deanna L. Schneider <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, April 25, 2000 10:23 AM
Subject: dynamic form field names


> Hi all,
> I know I should be able to figure this out, but my brain is not
cooperating.
>
> I have a form that has a user-defined number of options (user gets to pick
> how many categories a particular resource fits into). Now, typically, I'd
> name all the select boxes the same, and voila! I'd loop through the list
of
> form variables. But, because I'm using javascript to dynamically populate
> the subcategory select box, all the select boxes need unique names. Soooo,
> I'm looping through them and incrementing their names by 1 (i.e. two
> categories would result in form.catid1, form.catid2, form.subcat_id1 and
> form.subcat_id2 being passed to the action page). I'm also passing two
> hidden fields with the resource id (res_id) and the number of categories
> (looplength).
>
> On the action page, I thought I could loop based on the looplength
variable,
> and get the corresponding values. But, all I'm able to get is the names of
> the form fields. *sigh* I'm obviously not using "evaluate()" correctly.
> (And, yes, I know I could do a two dimensional array. I'm just using two
> one-dimensional arrays so that I know I'm not just screwing up the array
> structure.)
>
> Help?
>
> <cfset catarray = arraynew(1)>
> <cfset subcatarray = arraynew(1)>
>
>
> <cfloop from="1" to="#form.looplength#" index="i">
> <cfoutput>
> <cfset catarray[i] = "evaluate(form.cat_id#i#)">
> <cfset subcatarray[i] = "evaluate(form.subcat_id#i#)">
>
> </cfoutput>
> </cfloop>
>
>
>
<!--------------------------------------------------------------------------
> -
> Loop a query to insert data into the res_cat table.
> --------------------------------------------------------------------------
--
> -->
> <cfloop from="1" to="#form.looplength#" index="i">
> <cfquery name="insertcat" datasource="#application.dsn#">
> INSERT INTO  res_cat(res_id, cat_id, subcat_id)
> VALUES   (#form.res_id#, #catarray[i]#, #subcatarray[i]#)
> </cfquery>
>
> </cfloop>
>
>
> ************************************************************
> Deanna Schneider
> Interactive Media Developer
> UWEX Cooperative Extension Electronic Publishing Group
> 103 Extension Bldg
> 432 N. Lake Street
> Madison, WI 53706
> (608) 265-7923
>
>
>
> --------------------------------------------------------------------------
----
> Archives: http://www.eGroups.com/list/cf-talk
> 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.eGroups.com/list/cf-talk
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.

Reply via email to