Entry
How to do a select multiple?
Nov 18th, 2006 04:47
yoss chang, Nathan Wallace, Ryan Seager, Onno Benschop, Nick Talbott
The principle is to use an array name as the variable name in the
<select> tag - in your case 'foo[]'. Here's a complete self-contained
example I posted to this list last year.
<HTML><HEAD></HEAD>
<BODY>
<H2>Using multiple select</H2>
<?php
$num_selected = count($sel);
if ($num_selected)
{
print "Number of options selected: $num_selected<p>\n";
print_r($_POST['sel']);
}
?>
<form method=post>
<select name=sel[] multiple size=3>
<option value=red>Red
<option value=green>Green
<option value=blue>Blue
<option value=brown>Brown
<option value=black>Black
</select>
<br>
<input type=submit value="Submit">
</form>
</BODY></HTML>