Jump to content

POST a multiple select?


libertyct

Recommended Posts

I have simplified what i am trying to do and I setup an example below. basically im trying to figure out how to capture data posted from a Select with multiple options selected. any ideas?

 

<form name="form" method="post" action="save.php" >

 

<select name="categories" multiple >

      <option value="1" >1</option>

      <option value="2" selected >2</option>

      <option value="3" selected >3</option>

</select>

 

<input type="submit" value="submit" />

 

 

thnx!

Link to comment
https://forums.phpfreaks.com/topic/127643-post-a-multiple-select/
Share on other sites

this is tested and works  just gotta edit your details in

<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<select name="test[]" multiple="multiple">
<option value="one">one</option>
<option value="two">two</option>
<option value="three">three</option>
<option value="four">four</option>
<option value="five">five</option>
</select>
<input type="submit" value="Send" />
</form>

 

<?php
$test=$_POST['test'];
if ($test){
 foreach ($test as $t){echo 'You selected ',$t,'<br />';}
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.