此文件为05.php
<html>
<head>
<title>下拉列表的演示</title>
</head>
<body>
<form method="post" action="05.php">
<h3>下拉菜单选择一项:</h3>
<select name="sel_a" size="1">
<option value="gansu" selected>甘肃省</option>
<option value="shanxi">陕西省</option>
<option value="zhejiang">浙江省</option>
<option value="jilin">吉林省</option>
<option value="sichuan">四川省</option>
</select>
<br><br><br>
<select name="sel_b" size="1">
<option value="baiyin" selected>白银市</option>
<option value="xianyang">咸阳市</option>
<option value="ningbo">宁波市</option>
<option value="baicheng">白城市</option>
<option value="chengdu">成都市</option>
</select>
<br><br><br>
<input type="submit" value="提交">
</form>
</body>
</html>
<?php
if($_POST)
{
echo "<hr>";
$sel_a = $_POST['sel_a'];
$sel_b = $_POST['sel_b'];
if($sel_a == 'gansu')
{
echo "甘肃省 vs";
}
elseif ($sel_a == 'shanxi')
{
echo "陕西省 vs";
}
elseif ($sel_a == 'zhejiang')
{
echo "浙江省 vs";
}
elseif ($sel_a == 'jilin')
{
echo "吉林省 vs";
}
elseif ($sel_a == 'sichuan')
{
echo "四川省 vs";
}
switch ($sel_b)
{
case 'baiyin':
echo " 白银市<br>";
break;
case 'xianyang':
echo " 咸阳市<br>";
break;
case 'ningbo':
echo " 宁波市<br>";
break;
case 'baicheng':
echo " 白城市<br>";
break;
case 'chengdu':
echo " 成都市<br>";
break;
}
}
?>