Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_php thread: Getting values from a multiselect field


Message #1 by "arun" <arun@l...> on Tue, 19 Mar 2002 11:00:57 -0800
Thanks nik.

regards
arun

-----Original Message-----
From: Nikolai Devereaux [mailto:yomama@u...]
Sent: Monday, March 18, 2002 9:42 PM
To: professional php
Subject: [pro_php] RE: Getting values from a multiselect field



Hi Arun,

I don't think you need to translate ASP to PHP here.  If you allow multiple
items to be selected, then you should name your input field accordingly.

---- formtest.php ----

<form method="get" action="formtest.php">
   <select name="boogas[]" multiple>
     <option value="booga 1">opt1</option>
     <option value="booga 2">opt2</option>
     <option value="booga 3">opt3</option>
   </select>
   <input type="submit">
</form>

<pre>
<?php
print_r($HTTP_GET_VARS);
?>
</pre>
------------------------

gives this output when I submit the form with the first two options checked.

Array
(
    [boogas] => Array
        (
            [0] => booga 1
            [1] => booga 2
        )
)

With only the last option checked, I get this:
Array
(
    [boogas] => Array
        (
            [0] => booga 3
        )
)


So you see, you already have the values from a <select multiple> in an
array.


Take care,

Nik




  Return to Index