Thursday, 19 February 2015

PHP select box multiple selections

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

0 comments:

Post a Comment