Skip to main content
Inspiring
September 9, 2010
Answered

Exclude form fields from cfloop

  • September 9, 2010
  • 1 reply
  • 1261 views

Is there anyway to exclude some form fields while looping over others?  If I could just not loop over certain form fields on the action page it would be perfect. Not sure if this is possible.  I am passing items from the form and appending or deleting them to a list....but I don't want all of the form fields to do this.

Right now the code is:

<cfloop list="#form.fieldnames#" index="i" delimiters=",">

Doing functions in here to append, delete items from the form into a list.

</cfloop>

    This topic has been closed for replies.
    Correct answer ilssac

    You could just add a conditional statement to your loop.  Something like this might work.

    <cfif listContains(i,"list,of.fields,to,include")>

    OR

    <cfif NOT listContains(i,"list,of,fileds,to,exclude")>

    1 reply

    ilssac
    ilssacCorrect answer
    Inspiring
    September 9, 2010

    You could just add a conditional statement to your loop.  Something like this might work.

    <cfif listContains(i,"list,of.fields,to,include")>

    OR

    <cfif NOT listContains(i,"list,of,fileds,to,exclude")>

    brianismAuthor
    Inspiring
    September 9, 2010

    Well the form fields are always going to be present and I need to pass them for a different part of the page.  I guess

    what I am looking for is the CFLOOP to only loop over certain form fields, not all of them.  I don't know if that is possible.


    Inspiring
    September 9, 2010

    Create a list of fields you want to include and loop through that.