document.write('
解析:
<!DOCTYPE html PUBLIC "-//W3C//DTD xhtml 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=gb2312"
/>
<title> 如何获取表单 <select> 域的选择部分的文本 zgbn</title>
</head>
<script type="text/JavaScript">
function test() {
var selectO = document.getElementById("select");
var s = selectO.value ; // 获取已经选择的值
var i = selectO.selectedIndex ;// 获取选择第几个选
项的索引
var op = selectO.options ;// 获取所有选项的集合
var t = op.text ;// 获取指定索引的集合中元素的文本
alert(t) ;
}
</script>
<body>
<select name="select" id="select">
<option value=1>11</option>
<option value=2>22</option>
<option value=3>33</option>
<option value=4>44</option>
<option value=5>55</option>
</select>
<input type="button" value=" 单击 " onclick=
"test()" />
</body>
</html>
<html>
<head>
<title></title>
<script>
function sel(obj){
alert(" 显示文本:"+obj.options[obj.selectedIndex].text);
alert(" 值:"+obj.options[obj.
selectedIndex].value);
}
</script>
</head>
<body>
<form name="a">
<select name="a" size="1" onchange=
"sel(this)">
<option value="a" >1</option>
<option value="b" >2</option>
<option value="c" >3</option>
</select>
</form>
</body>
</html>
');