The Easiest Way to make a form!

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!



All ColdFusion Tutorials By Author: Alex Allen-Turl
  • Creating a Link Management System
    This quick tutorial, shows you how to creat a Link system, that will count the amount of hits that your links create.
    Author: Alex Allen-Turl
    Views: 17,096
    Posted Date: Tuesday, December 17, 2002
  • Creating a Voting System
    This is a very quick tutorial on how to create a voting system for page relavances and other such things from a scale of 1 to 5!
    Author: Alex Allen-Turl
    Views: 17,584
    Posted Date: Saturday, December 21, 2002
  • Creating Databases in MS SQL2000
    How to get your Data into MS SQL2000 and interface with Coldfusion in 34 Easy Steps!
    Author: Alex Allen-Turl
    Views: 19,664
    Posted Date: Sunday, December 15, 2002
  • Creating Dynamic Bar Charts
    A tutorial showing you how you can create a dynamic bar chart!
    Author: Alex Allen-Turl
    Views: 18,601
    Posted Date: Tuesday, December 24, 2002
  • Creating Dynamic Image Galleries
    A tutorial showing you how you can upload one Full sized picture, and have a thumbnail automatically created for you, along with descriptions of the image!
    Author: Alex Allen-Turl
    Views: 28,348
    Posted Date: Tuesday, December 24, 2002
  • Creating Relationships with ColdFusion
    This tutorial shows how you create Relationships between tables to speed up queries and decrease the overall size of the database
    Author: Alex Allen-Turl
    Views: 13,861
    Posted Date: Friday, December 13, 2002
  • Extensionless Coldfusion
    Ever wanted to be like google and run your scripts without an extension? This tutorial shows you how with Apache or IIS!
    Author: Alex Allen-Turl
    Views: 9,391
    Posted Date: Thursday, October 27, 2005
  • The Easiest Way to make a form!
    This is by far the most easiest and simplest way to make a form and update it to the database, very low maintenance and very very quick!!
    Author: Alex Allen-Turl
    Views: 19,529
    Posted Date: Tuesday, December 24, 2002