Skip to main content
Known Participant
September 7, 2009
Question

How do I get the second or third fields from the list form.fieldnames ?

  • September 7, 2009
  • 2 replies
  • 667 views

In a related post :

I have this code :

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

When I use cfdump to display all the form variables, the struct fieldnames are :

urdn_action,del/8084/1,comments/8084/1,xxxxxxxxx...etc

The first fieldname, urdn_action, is a radio button.

How do I get to the second fieldname, del/8084/1, or the third one, comments/8084/1 ?

I need to manipulate either the second or third field to extract 8084 and 1, to do further processing.  My code won't work now because the fieldname urdn_action is the first form fieldname and is gettting in the way. How do I skip it to get to the others ?

Thanks

    This topic has been closed for replies.

    2 replies

    BKBK
    Community Expert
    Community Expert
    September 7, 2009

    field2 = listGetAt(form.fieldnames,2)

    field3 = listGetAt(form.fieldnames,3)

    alternatively

    fields = arrayNew(1)

    fields = listToArray(form.fieldnames)

    field2=fields[2]

    field3=fields[3]

    Inspiring
    September 7, 2009

    Read up the docs on how the following constructs work:

    <cfloop> (list):

    http://livedocs.adobe.com/coldfusion/8/htmldocs/Tags_j-l_15.html#3205709

    You shoud be most of the way there with the code that you've got.

    Also:

    listGetAt():

    http://livedocs.adobe.com/coldfusion/8/htmldocs/functions_l_12.html#130923

    Probably read of list functions in general:

    http://livedocs.adobe.com/coldfusion/8/htmldocs/functions-pt0_13.html#1099435

    --

    Adam