Uwe Birkenhain wrote:
> Hi everybody on this rainy morning!

Rainy!? It's damn hot in Kiev :)

> My problem:
> I give the user a form with a list of options with checkboxes.
> The list is long and not predictable - the values change always.
> I want to put the checked values (or all, that doesn't matter) in an array,
> to pass it to my function.
> 
> How can I write those keys and values in an array?
> 

Suppose you have a number of checkboxes. First, you name them 
sequentially (like "active_0,active_1 and so on) and you assign it your 
value. Then you process posted data like this. BEWARE! you need at least 
an array of hidden variables to know exactly how many checkboxes you 
must process. Then you just rebuild it the structure and pass it thru.

   # put the received input into an ordered structure
   ##################################################
   $count = 0;
   while ( isset($id[$count]) ) {

     # Build variable names;
     #######################
     $w_active   = "active_".$count;

     # get actual form values
     ########################
     $active[$count]   = $$w_active;

     $count++;
   }

Hope it solves the problem. I've been using this for ages and it never 
gave me problems.

Alberto
Kiev

-- 


@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@

LoRd, CaN yOu HeAr Me, LiKe I'm HeArInG yOu?
lOrD i'M sHiNiNg...
YoU kNoW I AlMoSt LoSt My MiNd, BuT nOw I'm HoMe AnD fReE
tHe TeSt, YeS iT iS
ThE tEsT, yEs It Is
tHe TeSt, YeS iT iS
ThE tEsT, yEs It Is.......


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to