How to generate Dynamic Forms!
------------------------------
There are 2 ways to create and add forms the easy way, and the long way!
The long way entails setting out each form element
and specifying everything, and then the update which can be long and just as tedious.
But, sometimes, there can be an easier way,
Here is the absolute quickest way
Form.cfm
---------
<html>
<body>
<!--- these are the names of the input boxes that will be laid out
these have to match column names in your database to work --->
<cfset address1="Firstname,Lastname,Phone,Address1,Address2,City,County,PostCode">
<!--- this is for when the form loops back on itself the insert is there to tell it the form is to be invoked if there is form.insert then we load add_address, a simple one line of code to update the database! --->
<cfif isdefined("form.insert")>
<cfif form.insert eq 'insert'>
<cfinclude template="add_address.cfm">
</cfif>
</cfif>
<!--- create a table for our form to sit in --->
<table border=0 width=100%>
<tr>
<td colspan=2 bgcolor=silver><font
face='verdana'
size=2>Address</font></td>
</tr>
<cfoutput>
<!--- make sure it loops back on itself --->
<form action="index.cfm"
method="post">
<!--- this is the hidden input to let it know its been invoked --->
<input type="hidden"
name="insert"
value="insert">
<!--- now we cycle through the fields we've created --->
<cfloop list="#address1#"
index="i">
<tr>
<td><font
face="arial"
size=1>#i#</font></td>
<td><input
type="text"
name="#i#"
width="20"></td>
</tr>
</cfloop>
</cfoutput>
</table>
<input type="submit"
value="Continue >>">
</form>
</body>
</html>
now we add to the database!
Add_address.cfm
---------------
<cfinsert datasource="#application.dsn#"
formfields="#address1#"
tablename="address">
and thats it, the easiest, quickest way to add a form to a table!