Web 开发常用手册DHTML 参考手册 http://download.csdn.net/source/308913JScript 语言参考 http://download.csdn.net/source/308916CCS 样式表中文手册 http://download.csdn.net/source/304124
function getValue() { var len = document.selectform.checkbox.options.length; var arr = []; var opt; for (var i=0; i<len; i++) { opt = document.selectform.checkbox.options[i]; if (opt.selected) arr.push(opt.value); } alert(arr.join("\r")); return arr; }
楼主你看下实际的结构就应该知道怎么取值了
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="[email protected]" />
<meta name="keywords" content="" />
<meta name="description" content="" />
</head>
<body>
<form name="selectform" method="post" action="">
<select id="checkbox" size="5" multiple>
<option value="0">要啥</option>
<option value="1">宝马</option>
<option value="2">保时捷</option>
<option value="3">奔驰</option>
<option value="4">法拉利</option>
</select>
<input type="button" value="显示选中值" onclick="ShowSelectValues();" />
</form>
<script type="text/javascript">
<!--
function ShowSelectValues() {
var selectedValues = [];
var opt;
for (var i=0; i<document.selectform.checkbox.options.length; i++)
{
opt = document.selectform.checkbox.options[i];
if (opt.selected)
selectedValues.push(opt.value);
}
alert(selectedValues.join("\r"));
return selectedValues;
}
//-->
</script>
</body>
</html>
http://download.csdn.net/source/308913JScript 语言参考
http://download.csdn.net/source/308916CCS 样式表中文手册
http://download.csdn.net/source/304124
var len = document.selectform.checkbox.options.length;
var arr = [];
var opt;
for (var i=0; i<len; i++)
{
opt = document.selectform.checkbox.options[i];
if (opt.selected)
arr.push(opt.value);
}
alert(arr.join("\r"));
return arr;
}