Friday, January 28, 2011

PHP, process multiple select from dropdown menu


Create a dropdown menu, select multiple items which are processed by PHP

multi_select.php



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

1 comment:

  1. Hi,
    On this page:
    http://coursesweb.net/javascript/multiple-dropdown-select-lists-creator_s2
    it is a script that can be used to create Multiple Drop-Down Select Lists.
    Options data and the structure /levels of the Select lists are defined easily into an administration page.

    ReplyDelete