有俩个ListBox ,通过按钮可以移动里面的项(item),ListBox有个属性是ListSelectMode,值有"Single"和"Multiple",我设置值是"Multiple",就是可以选择多项,当我同时选择俩个时,如何把他们同时移动到另一个ListBox里面,谢谢朋友们帮忙...
解决方案 »
- 验证码
- cookieless="false"与true对服务器有什么区别?
- asp.netC#中怎样获取指定目录下的所有文件及属性。
- JS脚本加载用户控件问题
- 我的一个用户控件有Page_Load()和一个有get{}方法的属性.可是每次get{}方法总在Page_Load()之前执行,结果出错.不是说Page_Load是在控件载入的时候首先执行的吗?
- 用脚本寻找服务器控件的小问题,在线等..
- DataGrid的页眉的下拉列表事件
- 我在wind2000 advanced server 系统中装了netframework1.1,能不能再装VS.NET 2002吗?
- 如何写ASP.NET下的控件?请老大们指教!那儿可以下到有关学习资料?
- 哈哈哈,风水轮流转,终于轮到我结婚啦!
- 100分求算法,在线等,急急急
- 汇总sql问题,请各位帮忙!
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JavaScript">
<!--
function addSrcToDestList() {
destList = window.document.forms[0].destList;
srcList = window.document.forms[0].srcList;
var len = destList.length;
for(var i = 0; i < srcList.length; i++) {
if ((srcList.options[i] != null) && (srcList.options[i].selected)) {var found = false;
for(var count = 0; count < len; count++) {
if (destList.options[count] != null) {
if (srcList.options[i].text == destList.options[count].text) {
found = true;
break;
}
}
}
if (found != true) {
destList.options[len] = new Option(srcList.options[i].text);
len++;
}
}
}
}function deleteFromDestList() {
var destList = window.document.forms[0].destList;
var len = destList.options.length;
for(var i = (len-1); i >= 0; i--) {
if ((destList.options[i] != null) && (destList.options[i].selected == true)) {
destList.options[i] = null;
}
}
}
// -->
</SCRIPT>
</head>
<body>
<center>
<form method="POST">
<table bgcolor="#FFFFCC"><tr>
<td bgcolor="#FFFFCC" width="85">
<select size="6" name="srcList" multiple>
<option value="1">Item 1
<option value="2">Item 2
<option value="3">Item 3
<option value="4">Item 4
<option value="5">Item 5
<option value="6">Item 6
</select>
</td>
<td bgcolor="#FFFFCC" width="74" align="center">
<input type="button" value=" 增加到右边 " onClick="javascript:addSrcToDestList()">
<br><br>
<input type="button" value=" 从右边删除 " onclick="javascript:deleteFromDestList();">
</td>
<td bgcolor="#FFFFCC" width="69">
<select size="6" name="destList" multiple>
</select>
</td>
</tr>
</table>
</form>
</body>
</html>
添加事件的方法
protected void Button1_Click(object sender, EventArgs e)
{
int i=0;
while (i<ListBox1.Items.Count)
{
ListItem li = ListBox1.Items[i];
if (li.Selected)
{
ListBox2.Items.Add(li);
ListBox1.Items.Remove(li);
}
else
++i;
}
}
移除事件的方法
protected void Button2_Click(object sender, EventArgs e)
{
int i = 0;
while (i < ListBox2.Items.Count)
{
ListItem li = ListBox2.Items[i];
if (li.Selected)
{
ListBox1.Items.Add(li);
ListBox2.Items.Remove(li);
}
else
++i;
}
}