Jump to content


Photo

$_POST and multiple selects


  • Please log in to reply
3 replies to this topic

#1 Gaia

Gaia
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts
  • LocationCanada

Posted 30 April 2006 - 02:11 PM

Hi,

I have a form that has a multiple select ( where you can choose more then one option ) and i can't seem to figure out how to retrieve all the selected options with $_POST.

When i changed to $_GET, it showed in the url &option=1&option=4&option=5, etc.

So, I know they are being passed as the same variable, but I'm wondering how to retrieve them all via $_POST.

Thanks.

#2 Guest_askjames01_*

Guest_askjames01_*
  • Guests

Posted 30 April 2006 - 02:19 PM

if (isset($_POST['B1'])){
$contents = "Guest name: " . $_POST['gname'] .
"\n\nState: " . $_POST['gstate'] .
"\n\nZip: " . $_POST['gzip'] .
"\n\nCountry: " . $_POST['gcountry'] .
"\n\nE-mail: " . $_POST['gemail'];
}

i think this will give you an idea.


#3 Gaia

Gaia
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts
  • LocationCanada

Posted 30 April 2006 - 03:11 PM

What...

No, I know how to get the value of a single input...but I dont know how with a multiple select....

Thanks.

#4 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 30 April 2006 - 03:54 PM

You need to make the name of your select an array, then the multiple selections will be in the array:
<select name='test[]'>

Ken




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users