Hi Candace,

Sounds to me like you just need a brief refresher on "associative arrays".

Any given structure may be referenced with a dot, or with the [] you
normally see with arrays. If you need to dynamically build the structure
key, this is the way to go, and it works just like building any other
string, so as you're looping over i, you can say #form["field" & i]# or
#form["field#i#"]# , whichever you're more comfortable with to return the
value of the given form field.

> I want to make sure they arent saying they want to add
> 5 records and only add fill out the info for 3, so I
> add this conditional logic...

> <CFIF form.?? NEQ "" AND form.?? NEQ "">

I think you're looking for

<cfif form["field" & i] neq "">

or

<cfif len(trim(form["field" & i]))>

> ... however, how do I reference the dynamic form
> elements?? ANd then when I am ready to run the insert,
> how do I refererence the values that were entered into
> he dynamically-named elements??

> <CFQUERY DATASOURCE="APOOO">
>   <!--- run your insert or update query here --->
>   Insert Into Websites
>   (Website_Author, Website_Link)
>   Values ('#form.??#','#form.??#')
> </CFQUERY>

<CFQUERY DATASOURCE="APOOO">
  <!--- run your insert or update query here --->
  Insert Into Websites
  (Website_Author, Website_Link)
  Values ('#form["field" & i]#','#form["field" & i]#')
</CFQUERY>

Although I'd recommend adding <cfqueryparam> in there...

> And then, how do I reference these values once
> again when confirming the insert was successful??

>       <cfloop from="1" to="#form.NumForms#" index="i">
>                       <cfif #??# NEQ "" AND #??# NEQ "">
>                                       <cfoutput>
>                                                               <h1><a
> href="#form.??#" target="_blank">#form.??#</a>
>                                                               </h1>
>                                       </cfoutput>
>                       </cfif>
>       </cfloop>

<cfloop from="1" to="#form.NumForms#" index="i">
  <cfif #form["field" & i]# NEQ "">
    <cfoutput>
      <h1><a href="#form["field" & i]#"
      target="_blank">#form["field" & i]#</a></h1>
    </cfoutput>
  </cfif>

</cfloop>


> I am at a loss here and my brain could implode. I promise
> if you all
> help me with referencing this, I will post a tutorial on
> this or submit
> an article to Fusion Authority on how to do this.

> Much obliged :)

Also, I believe this subject is covered in Jim Davis' recent article on CF
variables at

http://www.depressedpress.com/DepressedPress/Content/ColdFusion/Guides/Varia
bles/Index.cfm

Jim and I are good friends and I know that he'd appreciate if you not only
let him know if you like the article, but let him know also if you feel like
there's anything in it that he left out or could be more elaborated.

hth...

s. isaac dealey                954-776-0046

new epoch                      http://www.turnkey.to

lead architect, tapestry cms   http://products.turnkey.to

tapestry api is opensource     http://www.turnkey.to/tapi

certified advanced coldfusion 5 developer
http://www.macromedia.com/v1/handlers/index.cfm?ID=21816

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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