Ok, I can't get this right... Have the following code:
<? $choices = array(1 => 'dog', 2 => 'cat', 3 => 'mouse', 4 => 'frog'); if (is_array($_REQUEST['animals'])) { // get the number of selectcases echo "get the number of selectcases: " . count($animals) . "<br>"; // get the number of provided selects from select with name "2" echo "get the number of provided selects from select with name \"2\": " . count($animals[2]) . "<br>"; // test to print some data echo $animals[2][0]. "<br>"; echo $animals[2][1]. "<br>"; echo $animals[2][2]. "<br>"; echo $animals[2][3]. "<br>"; } ?> <form method="post" action="<?= $_SERVER['PHP_SELF'] ?>"> <select multiple name="animals[2]"> <option value='1'>dog</option> <option value='2'>cat</option> <option value='3'>mouse</option> <option value='4'>frog</option> </select> <select multiple name="animals[4]"> <option value='1'>dog</option> <option value='2'>cat</option> <option value='3'>mouse</option> <option value='4'>frog</option> </select> <input type="submit"></form> Why does it not work? // get the number of selectcases echo "get the number of selectcases: " . count($animals) . "<br>"; This works great // get the number of provided selects from select with name "2" echo "get the number of provided selects from select with name \"2\": " . count($animals[2]) . "<br>"; But this doesn't... Thankful for any help, /Victor On Sunday, May 26, 2002, at 05:35 PM, John Holmes wrote: > You can supply an "whateverID" for the select if you want to. > > <select name="select[]"> > <option ... > </select> > > <select name="select[]"> > <option ... > </select> > > etc... > > That will give you an array $select[] on the processing page. If the > selects are multi-selects, you'll have a multidimensional array. The > first chosen element in the first select box can be referenced like this > > $select[0][0] > > You can get a count of how many select boxes there are by doing > > count($select); > > You can get a count of how many elements were selected within a select > you can do this: > > count($select[x]); > > Where x is the number of the select box you want to know about. > > Confusing, eh? > > ---John Holmes... > >> -----Original Message----- >> From: Victor Spång Arthursson [mailto:[EMAIL PROTECTED]] >> Sent: Sunday, May 26, 2002 7:44 AM >> To: [EMAIL PROTECTED] >> Subject: Re: [PHP] Need some advice concerning forms (multi select >> pulldown) and arrays >> >> >> On Sunday, May 26, 2002, at 01:14 PM, John Holmes wrote: >> >>> Just give each select its own name. >> >> Can't do that, don't know from time to time how many there'll be.... > And >> I've to have some case which iterates on the following page... >> >>> Or name them all the same followed >>> by an [] and you'll end up with a multi-dimensional array if things > go >>> right... >> >> Sounds better - but I've a lot of items and I'ld like to know which of >> the arrays that go to which item... Can I just write >> …name=array[whateverid] and then in some way reveal the whateverid's? >> >> Sincerely >> >> Victor > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php