There's a better, cleaner way of processing your form.

I would do this on the processing side.

<cfloop collection="#form#" item="thisField">
        <cfif FindNoCase(thisField,"item")>
                <cfset fieldname=thisField>
                <cfset fieldValue=Form[thisField]>
                 <cfquery>
                    INSERT inventory(item_ID,Group_item_ID ) 
                               values ('#fieldValue#',#form.Group_item#)
                    </cfquery>
        </cfif>

</cfif>

-----Original Message-----
From: j s [mailto:[EMAIL PROTECTED] 
Sent: Monday, February 27, 2006 1:28 PM
To: CF-Talk
Subject: Renaming dynamic form fields

I'm trying to figure out a way to pass form fields to a page which will
then rename the fields.

The reason is the fields are produced dynamically and not all the fields
will be passed since
they will be checkboxes. When I perform my db insert I do loop which
needs to have the fields
in order. If the fields that are passed are 1,2,3 out of 6 my insert
works. If the form passes fields
2,3,4 I get an error cause field 1 is not defined. 1,2,4 or 1,3,4 also
don't work since they are not
in order.

This is why I want to:

The first step I want to do is get the values from the form fields in
need into an array.

Then perform a loop to place the values into a the new form fields named
newName.


<!--- dynamic form --->
     <form action="tester.cfm" method="post" name="AddToCart"> 
          <cfoupt>
               <input name="Group_item" type="hidden"
value="#Group_item_ID#">
          </cfoutput>

               <label for="item">#item_name#</label>
                <cfoutput>
               <input value="#item_ID#" type="checkbox" type="radio"
name="item#CurrentRow#" />
           </cfoutput>                                                  
               <input name="Submit" type="submit" class="formButton"
value="Add to Cart" />
     </form>
<!--- end dynamic form --->

<!--- tester.cfm page --->

<!--- get the total number of form fields minus the submit and
group_item_ID fields  --->
     <cfset formCount = ListLen('#FORM.FieldNames#', ",")>
      <cfset formCount = formCount - 2>

<!--- here is where I want to put the item#CurrentRow# fields in array
--->

<!-- End -->

<!--- place the values into a new form name using the formCount --->

<!--- perform insert  using new form fields --->

     <cfloop from="1" to="#formCount#" index="i">
               <cfquery>
                    INSERT inventory
                              (item_ID,Group_item_ID ) 
                               values ('#Evaluate("form.newName#i#")#',
#form.Group_item#)
                    </cfquery>
                    </cfloop> 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:233603
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to