here is my code
Code: Select all
<html>
<head>
<title>PHP select box constructor demo</title>
</head>
<?
include "us_states.php";
function buildSelect($selArr, $selOpt){
foreach($selArr as $key => $value){
$sel = "";
for ($loop = 2; $loop < count($selOpt); $loop++) {
if ($selOptї$loop] == $key) {
$sel = "selected";
}
}
echo "<option $sel value='$key'>$value</option>\n";
}
return;
}
?>
<body>
<form method="POST" action="">
<select name="allstates" multiple size="6">
<?
$options = array( "", "", "AL", "CO");
buildSelect($allstates, $options)
?>
</select>
<input type="submit" name="Submit" value="Click this button to find out what you selected">
<? //this is where I want to display the state, this is what I'm trying but
//my display line does not work, can't display value when something
//is selected
if($REQUEST_METHOD == "POST"){
if($_POSTї$key] != "selected")
echo "you selected $_POSTї$key] ";
else
// empty
}
?>
</form>
</body>
</html>