Move Items Between 2 ListBoxes
来源:互联网 发布:系统预装软件不显示 编辑:程序博客网 时间:2024/06/10 18:12
Just wrote this little JavaScript snippet by request of a coworker in this rainy and moody morning:
<script>
function MoveItem(ctrlSource, ctrlTarget) {
var Source = document.getElementById(ctrlSource);
var Target = document.getElementById(ctrlTarget);
if ((Source != null) && (Target != null)) {
while ( Source.options.selectedIndex >= 0 ) {
var newOption = new Option(); // Create a new instance of ListItem
newOption.text = Source.options[Source.options.selectedIndex].text;
newOption.value = Source.options[Source.options.selectedIndex].value;
Target.options[Target.length] = newOption; //Append the item in Target
Source.remove(Source.options.selectedIndex); //Remove the item from Source
}
}
}
</script>
HTML Code: <table height="150" width="300"> Colt Kwong
<tr>
<td>
<asp:ListBox id="ListBox1" runat="server" Height="111px" SelectionMode="Multiple">
<asp:ListItem Value="1">One</asp:ListItem>
<asp:ListItem Value="2">Two</asp:ListItem>
<asp:ListItem Value="3">Three</asp:ListItem>
</asp:ListBox>
</td>
<td>
<p>
<input onclick="Javascript:MoveItem('ListBox1', 'ListBox2');" type="button" value="->" />
</p>
<p>
<input onclick="Javascript:MoveItem('ListBox2', 'ListBox1');" type="button" value="<-" />
</p>
</td>
<td>
<asp:ListBox id="ListBox2" runat="server" Height="111px" SelectionMode="Multiple">
<asp:ListItem Value="8">Eight</asp:ListItem>
<asp:ListItem Value="9">Nine</asp:ListItem>
<asp:ListItem Value="10">Ten</asp:ListItem>
</asp:ListBox>
</td>
</tr>
</table>
- Move Items Between 2 ListBoxes
- Move windows between multiple monitors
- How to move items to another category
- How to add dividers and spaces between items in RecyclerView?
- How to move between two or more forms?
- How to move an OIM database between two OIM instances
- Quickly move an executable between systems with ELF Statifier
- 2017 JUST Programming Contest 3.0 I. Move Between Numbers
- latex: ieeetran.bst - how to reduce row spacing between bib items
- memcached内存管理(2) ----------------items
- Move
- Move
- Move
- Move..
- Between
- Refactoring Day 2 : Move Method
- Vim学习笔记2---Move
- Move!Move!!Move!!!
- 事件句柄
- ARM中的RO、RW和ZI DATA
- #pragma 预处理指令详解
- 巨风网络提供国内最全的域名注册服务
- 委托事件的另类取消方法
- Move Items Between 2 ListBoxes
- PowerDesigner12.0 用法
- 解决南北互通瓶颈 服务器多线接入探讨
- 外国关于flash和flex 的技术杂志
- 电子商务:金融危机下IDC的新蓝海
- 又要上班了,总结一下
- 对CodeSmith + netTiers 生成DAL的一点补充
- 注册表从入门到精通
- C语言中memset函数详解