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.

Reply via email to