#form["field" & index]#

However, since they are checkboxes, you have to test for their existence
first using isDefined() or structKeyExists().

M!ke

-----Original Message-----
From: Dmitrii Dimandt [mailto:[EMAIL PROTECTED] 
Sent: Friday, August 04, 2006 8:03 AM
To: CF-Talk
Subject: Re: Form parameters as array

I know that :)

What I needed is a simple way to output and process a number of very
similar fields. Let's say, you want to ban 10 users from a forum at
once. After you've found these users, you could output this:

    <input type="checkbox" name="User[10][IsBanned]" value="banned" />
    <input type="checkbox" name="User[20][IsBanned]" value="banned" />
    <input type="checkbox" name="User[30][IsBanned]" value="banned" />
    etc.

After the form is submitted you could do this in PHP:

   while(list($key, $value) = each($_POST['User']))
   {
       /* $key now holds 10, 20, 30 ..., $val holds the value of the
checkbox */
   }

Additionally each field is accessible through
$_POST['User']['10']['isBanned'].

This is possible because PHP treats incoming fields with names like
User[10][isBanned] as associative arrays.

Unfortunately, in CF I cannot do access a field by writing
form.User['20']['IsBanned']. So I ended up writing my own function which
attempts to emulate this behaviour. I also wondered whether there
already was a function somewhere emulating this behaviour. Alas.
:)  :(

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:248790
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to