Don't make the explicit distiction between a multiform and a singleform, 
the singleform *is* the multiform with i=1. Some more comments are inline.

Form page:

<cfparam name="MultiForm" default="FALSE">
<cfparam name="i" default="1">

<!--- use CSS :) -->
<cfhtmlhead text='
<style type="text/css" media="screen">
table.full {
        width: 100%;
        border: 0;
        cellspacing: 2;
        cellpadding: 5
        }
td.copyTeal {
        text-align: right;
        vertical-align: top
        }
</style>
">

<form action="addSite2.cfm" method="post" name="addSite">
<table class="full">

<cfoutput>
<cfloop from="1" to="#URL.NumForms#" index="i">

<tr>
        <td width="24%" class="copyTeal">
                Author Name:
        </td>
        <td width="76%">
                <input name="Website_author#i#" type="text">
        </td>
</tr>
<tr>
        <td class="copyTeal">
                Website link:
        </td>
        <td>
                <input name="Website_Link#i#" type="text" size="45">
                <p><span class="tealHeader">Please include the http:// and remember to 
verify the link's accuracy.</span></p>
        </td>
</tr>

</cfloop>
</table>

        <input name="NumForms" type="hidden" value="#NumForms#">
        <p class="tealHeader">
                <input type="submit" value="Continue">
        </p>
</form>
</cfoutput>


Action page:


<cfparam name="form.NumForms" type="numeric">
<CFLOOP INDEX="i" FROM="1" TO="#form.NumForms#">
        <CFIF Len(Trim(form["Website_author#i#"])) AND 
Len(Trim(form["Website_Link#i#"]))>

                <!--- Needed because of Trim() and cfqueryparam bug --->
                <cfset tempAuthor = Trim(form["Website_author#i#"])>
                <cfset tempLink = Trim(form["Website_Link#i#"])>

                <CFQUERY DATASOURCE="APOOO">
                <!--- run your insert or update query here --->
                INSERT INTO Websites (
                        Website_Author,
                        Website_Link
                        )
                VALUES (
                        <cfqueryparam cfsqltype="cf_sql_varchar" value="#tempAuthor#">,
                        <cfqueryparam cfsqltype="cf_sql_varchar" value="#tempLink#">
                        )
                </CFQUERY>

<!--- Mixing display code with action code is probably bad, but else I 
have to type it twice :) --->

                <cfoutput>
                        <h2>
                        <a href="#form.??#" target="_blank">
                                #form.??#
                        </a>
                        </h2>
                </cfoutput>

        <cfelse>
        <CFIF Len(Trim(form["Website_author#i#"]))>
                <cfouput>
                Unsuccessful add.<br />
                #form["Website_author#i#"]# submitted without link.
                </cfoutput>
        <cfelseif Len(Trim(form["Website_Link#i#"]))>
                <cfoutput>
                Unsuccessful add.<br />
                #form["Website_Link#i#"]# submitted without link.
                </cfoutput>
        <cfelse>
        <!--- Why would you want to display something here at all? --->
                Unsuccessfull add, no link and author provided.
        </cfif>
</cfloop>


Good luck with the tutorial,

Jochem

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to