关于

luwq1976 2008-01-14 11:13:12
<select size=** multiple>
通常情况下是用 Ctrl 键配合鼠标实现多选,请问各位高手,如果不用ctrl键,只用鼠标,怎么可以实现多选?
...全文
167 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
luwq1976 2008-01-14
  • 打赏
  • 举报
回复
楼上兄第,快把代码贴出来
yixianggao 2008-01-14
  • 打赏
  • 举报
回复
呵呵,俺早就写过一贴,单击选中,再次单击取消!

不过找不到了,一会儿重写一个,哈
luwq1976 2008-01-14
  • 打赏
  • 举报
回复
我的意思是怎么用代码去实现,而不是拖着鼠标不放.
西安风影 2008-01-14
  • 打赏
  • 举报
回复
也就是画个正方形
西安风影 2008-01-14
  • 打赏
  • 举报
回复
点住不放向下拖就可以多选
yixianggao 2008-01-14
  • 打赏
  • 举报
回复
注意:不支持鼠标拖选,只能点选!
单击选中,再次单击取消!
yixianggao 2008-01-14
  • 打赏
  • 举报
回复
原来那个是IE版滴,现在这个可以兼容FF,
可是发现FF下Select的onchange和onclick事件顺序与IE相反,
因此一旦选择就必须至少选择一项,无法全部取消,除非额外增加清空按钮!
L@_@K
<!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>
<title> new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="Gao YiXiang" />
<meta name="email" content="yixianggao@126.com" />
<meta name="keywords" content="javascript dhtml dom" />
<meta name="description" content="I love web development." />
</head>
<body>
<select id="sltTest" multiple size="5">
<option value="0">-- Please select --</option>
<option value="1">option 01</option>
<option value="2">option 02</option>
<option value="3">option 03</option>
<option value="4">option 04</option>
</select>

<script type="text/javascript">
<!--
Array.prototype.indexOf = function(target)
{
var result = -1;

for (var i=0; i<this.length; i++)
{
if (this[i] == target)
{
result = i;
break;
}
}

return result;
};

var oSlt = document.getElementById("sltTest");
oSlt.selectedList = new Array();
oSlt.onchange = function()
{
with (this)
{
var i = selectedList.indexOf(selectedIndex);

if (i == -1)
{
selectedList.unshift(selectedIndex);
}
else
{
options[selectedIndex].selected = false;
selectedList.splice(i, 1);
}

for (var i=0; i<selectedList.length; i++)
{
options[selectedList[i]].selected = true;
}
}
};
//-->
</script>
</body>
</html>
luwq1976 2008-01-14
  • 打赏
  • 举报
回复
CSDN的高手都去哪里了?

61,126

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧