I have the need to create a data entry form that <br>
spans multiple pages (it's a long form - so I want to<br>
divide it 3 sepearate pages). How do you use CFINSERT to insert the data? NOTE: all data goes to ONE table (MS ACCESS)
You could "forward" the data from each page of the form using hidden form fields, then all the data will be together for the last cfinsert....<br>
<br>
example:<br>
<br>
PAGE 1<br>
<input type="text" name="clientname"><br>
<br>
PAGE 2<br>
<input type="hidden" name="clientname" value="#form.clientname#"><br>
<input type="text" name="clientaddress"><br>
<br>
PAGE 3<br>
<input type="hidden" name="clientname" value="#form.clientname#"><br>
<input type="hidden" name="clientaddress" value="#form.clientaddress#"><br>
<input type="text" name="clientemail"> <p>Doug Trocino<br><a href=mailto:dtrocino@tecumsehgroup.com>dtrocino@tecumsehgroup.com</a><br><a href=
The Idea of using hidden form fields can be made a lot easier by using a custom tag.. I took the initial idea from Ben Forta and made it a lot easier to understand.<br>
<br>
Create a page called embedfields.cfm in your c:\cfusion\custom tags directory. The page should consist of the code below:<br>
<br>
<cfsetting enablecfoutputonly="Yes"><br>
<CFIF IsDefined("FORM.fieldnames"><br>
<cfloop index="Var" list="#fieldnames#"><br>
<cfoutput><br>
<input type="Hidden" name="#var#" value="#evaluate('form.' & var)#"><br>
</cfoutput><br>
</cfloop><br>
</CFIF><br>
<cfsetting enablecfoutputonly="no"><br>
<br>
Nothing else... no <html> or <body> tags just the code above.<br>
<br>
Next you need to run it from your code and always within form tags. eg. <br>
<form method="post" action="page3.cfm><br>
<cf_embedfields><br>
</form><br>
<br>
What the tag does is take the form fields posted from the previous page and dumps them to Hidden<br>
Form fields. So the tag isn't needed on the first page only on the pages with forms that follow.<br>
<br>
Your <cfinsert> should only then need to define the table and datasource to put all the data in thats all.<br>
<br>
If you need to skip some form fields before they go into <cfinsert> then use the code below just before your <cfinsert> tag:<br>
<br>
<cfset mylist=""><br>
<cfloop list="#fieldnames#" index="var"><br>
<!--- define fields to skip here ---><br>
<cfif (#var# is "timestamp" or (#var# is "recordid" or (#var# is "action" or (#var# is "override"><br>
<cfelse><br>
<!--- Include all other fields into variable mylist ---><br>
<cfset mylist=#ListAppend(mylist, var)#> <br>
</cfif><br>
</cfloop><br>
<br>
Your <cfinsert> should then be <CFINSERT datasource="yourds" TABLENAME="yourtable" FIELDS="#mylist#"><br>
<br>
Problem solved.....<br>
<br>
Arachind....
Awesome!!!! I <b><i>LOVE</i></b> a solution that automates the process..... <p>Doug Trocino<br><a href=mailto:dtrocino@tecumsehgroup.com>dtrocino@tecumsehgroup.com</a><br><a href=
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.