<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>

解决方案 »

  1.   

    我的要求是在选择了上海市label中任何一个区的值后要同时取得label"上海市","XX区"值....在线等待.....
      

  2.   

    试一下:<option value='黄浦区'>黄浦区</option>...
    建议用Struts标签,会方便好的
      

  3.   

    <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].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>