在JavaScript中获取下拉菜单中的值

来源:百度知道 编辑:UC知道 时间:2024/05/26 08:51:10
如获得aaaa。ssss
<form name="myForm">
<select name="mySel">
<option>aaaa</option>
<option>ssss</option>
<option>dddd</option>
<option>ffff</option>
</form>

参考方法如下:
<!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=utf-8" />
<title> JS 获取下拉框中的值 </title>
<SCRIPT LANGUAGE="JavaScript">
function add() {
var obj = document.getElementByIdx_x("view");
var index = obj.selectedIndex;
var value = obj.options[index].text;
document.getElementByIdx_x("here").value = value;
}
</SCRIPT>
</head>
<body>
<select id="view" name="p