> Hi,
>
>    That didn't solve my problem. It is not even recognising the
> Form.FieldNames
>
>       <CFLOOP list="#form.fieldnames#" index="formField">
>               #formField# = #evaluate('form' &formField)# <br />
>       </CFLOOP>
>
>       it is giving error in the first line of the above code.
>
> Any more suggestions.
>
> Thanks,
> Sudheer Chakka.



Hi there!

A few things to note:

As far as I know, from CF 4.5 on, the FORM scope has been a structure.  One
thing I noticed about the FORM structure is that it will exist regardless of
what page you are on, meaning if you click a link that goes to a page with
just text (a cfm page, of course), the FORM structure is still available,
just like if you had submitted a form on that previous page.

That said, with the FORM scope being a structure, you can write cleaner,
faster code by excluding the Evaluate() function, like so:

<!--- FORM struct output, example 1 --->
<cfoutput>
<cfloop list="#form.fieldnames#" index="formField">
        #formField# = #FORM[formField]#<br />
</cfloop>
</cfoutput>

You can even go further, by looping over the FORM structure with the
collection attribute in the cfloop tag:

<!--- FORM struct, example 2 --->
<cfoutput>
<cfloop collection="#FORM#" item="formField">
        #formField# = #FORM[formField]#<br />
</cfloop>
</cfoutput>


Note that the second example will also display the form field
"FORM.fieldnames", unlike the first example where you are actually looping
over that field, which is in fact a list of all your fieldnames, except that
one... Get it? ;)

You can stick the second example in any page and it should work, regardless
of if a form was submitted.  The FORM scope will be empty in this case.  The
first requires that a form was submitted, since FORM.FIELDNAMES won't exist
if a form wasn't submitted.


--Andy


______________________________________________________________________
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to