<html>
<head>
<title>My test</title>
</head>
<body>
<hr>
<center>
<font size=5 color=red>我的测试</font>
</center>
<br>
<center>
<select onchange="alert(this.options[this.selectedIndex].text)">
<optgroup label="上海市">
<option>黄浦区</option>
<option>卢湾区</option>
<option>静安区</option>
<option>徐汇区</option>
<option>虹口区</option>
<option>闸北区</option>
</optgroup>
</select>
</center>
</body>
</html>
<head>
<title>My test</title>
</head>
<body>
<hr>
<center>
<font size=5 color=red>我的测试</font>
</center>
<br>
<center>
<select onchange="alert(this.options[this.selectedIndex].text)">
<optgroup label="上海市">
<option>黄浦区</option>
<option>卢湾区</option>
<option>静安区</option>
<option>徐汇区</option>
<option>虹口区</option>
<option>闸北区</option>
</optgroup>
</select>
</center>
</body>
</html>
建议用Struts标签,会方便好的
<head>
<title>My test</title>
</head>
<body>
<hr>
<center>
<font size=5 color=red>我的测试</font>
</center>
<br>
<center>
<select onchange="alert(this.options[this.selectedIndex].parentElement.label+','+this.options[this.selectedIndex].text)">
<optgroup label="上海市">
<option>黄浦区</option>
<option>卢湾区</option>
<option>静安区</option>
<option>徐汇区</option>
<option>虹口区</option>
<option>闸北区</option>
</optgroup>
</select>
</center>
</body>
</html>