Jump to content

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 />';}
}
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.