Kod:
<HTML><HEAD><title>multiple selection</title></HEAD>
<BODY>
<H2>Select Box -- Çoklu Seçim</H2>
by <A HREF="http://daevid.com" TARGET="daevid">Daevid Vincent</A>
<?
// by Daevid Vincent
function inList($needle, $haystack)
{
while (list($k, $v) = each($haystack)) if ($needle == $v) return true;
return false;
}
function selectBox($size, $name, $matchArray)
{
settype($matchArray, "array"); //we have to force this because on the first pass,this is set to string and will STB.
echo "<select multiple name='".$name."[]' size='".$size."'>\n";
for ($x = 0; $x < 5; $x++)
{
echo "\t<option value='key".$x."'";
if (inList("key".$x, $matchArray)) echo " SELECTED";
echo ">Value ".$x."\n";
}
echo "</select>";
} //selectBox()
////////////////////////////////////////////////////////////////////////
$num_selected = count($sel);
print "<P>Seçili Olan Kayıt Sayısı: $num_selected<p>\n";
if ($num_selected)
{
echo "<P>Seçili Olanlar:<BR>\n";
while (list($k, $v) = each($sel))
{ echo "sel[".$k."] == ".$v."<BR>\n"; }
}
?>
<form method="post">
<? selectBox(6,sel,$sel); ?>
<br>
<input type=submit value="Submit">
</form>
</BODY></HTML>