下面的代码实现删除select列表中同时删除选中的多个值。
\n
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
<html>
<head>
<title> New Document </title>
</head>
<script language=”JavaScript”>
//删除选择项
function deleteSelected(){
var s = document.getElementById(“categoryList”);
var length = s.length;
//从最后一个开始循环
for(var i=length-1;i>-1;i–){
var o = s.options[i];
if(o.selected==true){
s.remove(i)
}
}
}
</script>
<body>
<select id=”categoryList” multiple=”multiple” size=”11″ style=”width:300px” >
<option value=”1″ >设计家园</option>
<option value=”2″>酷站欣赏</option>
<option value=”3″>网页素材</option>
</select>
<input type=”button” value=”删除” onclick=”deleteSelected()”>
</body>
</html>