转自:
http://blog.csdn.net/haoxinqing9698/article/details/8057707
很简单的select标签:
<select id="hello" onchange="getContent(this.value,this.options[this.selectedIndex].text)">
<option value=1>a</option>
<option value=2>b</option>
<option value=3>c</option>
<option value=4>d</option>
</select>
以上是select的onchange方法,传了两个参数,分别是选中的option的Value(this.value)和选中的option的内同(this.options[this.selectedIndex].text)。这样就可以在onchange方法中直接使用值和内容了。
可以通过全局变量获得值,然后其他地方可以使用:
var text;
function getContent(value,content){
alert("选中的值是"+value+"选中的内容是"+content);
text = content;
}