一款很简单的利用js来获取select当前选中项的值代码,在select有个特别当前值应该是获取它的options的selectedindex的值,这样我们就可以如ojb.options[obj.selectedindex].value来获取了。
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.jzread.com/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>网页特效 获取select的值实现代码</title>
<script language="javascript">
function tttg()
{
var value =document.myfm.cc.options[document.myfm.cc.selectedindex].value;
alert(value);
}
</script>
</head>
<body>
<form name="myfm">
<select name="cc" onchange="tttg();">
<option value="1">1</option>
<option value="2">3</option>
<option value="3">3</option>
<option value="www.jzread.com">www.jzread.com</option>
<option value="5">mb.jzread.com</option>
</select>
</form>
</body>
</html>