两个列表框的javascript(将所选项目从第一个列表框移动到第二个列表框) [英] javascript for two listbox (move selected item from first listbox to second listbox)
本文介绍了两个列表框的javascript(将所选项目从第一个列表框移动到第二个列表框)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个语言列表框
我用按钮完成了(添加,删除)
但是
i希望在javascript中为两个列表框(将所选项目从第一个列表框移动到第二个列表框)
整体我想说
如果我在第一个列表框项目中双击,那么双击(选中)项目在第二个列表框中移动
i尝试但未成功..
请帮助我..对于这些
i have two listbox for languages
and i done it with button(add,remove)
but
i want in javascript for two listbox (move selected item from first listbox to second listbox)
overall i want to say that
if i doubleclick in first listbox item then that doubleclicked(selected) item move in second listbox
i tried but not success..
pls help me..for these
推荐答案
从这里你可以使用jquery做到这一点...我给你一些很好的链接...
http://www.dotnetspark.com/kb/1683-add-remove-items-from-one-listbox-to-another.aspx [ ^ ]
http://www.aspsnippets.com/Articles/How-to-move-ListBox-items -to-ListBox-in-ASPNet-using-jQuery.aspx [ ^ ]
http://aspsnippets.com/demos/601/ [ ^ ]
http://aloksah.org/2011/02/27/list-box-manipulation/ [ ^ ]
from here u can do this using jquery...i give u some good links...
http://www.dotnetspark.com/kb/1683-add-remove-items-from-one-listbox-to-another.aspx[^]
http://www.aspsnippets.com/Articles/How-to-move-ListBox-items-to-another-ListBox-in-ASPNet-using-jQuery.aspx[^]
http://aspsnippets.com/demos/601/[^]
http://aloksah.org/2011/02/27/list-box-manipulation/[^]
做到了......完成的工作...
did it...complete works...
<script type="text/javascript">
function lstDblClicked() {
var left_lst = document.getElementById("<%=_lbBox.ClientID%>");
var right_lst = document.getElementById("<%=_lbBox0.ClientID%>");
for (var i = 0; i < left_lst.length; i++) {
if (left_lst.options[i].selected == true) {
right_lst.options[right_lst.length] =
new Option(left_lst.options[i].text,
left_lst.options[i].value);
left_lst.options[i] = null;
i = i - 1;
}
}
return;
}
</script>
<script type="text/javascript">
function lstDblClicked1() {
var left_lst = document.getElementById("<%=_lbBox.ClientID%>");
var right_lst = document.getElementById("<%=_lbBox0.ClientID%>");
for (var i = 0; i < right_lst.length; i++) {
if (right_lst.options[i].selected == true) {
left_lst.options[left_lst.length] = new Option(right_lst.options[i].text, right_lst.options[i].value);
right_lst.options[i] = null;
i = i - 1;
}
}
return;
}
</script>
************************************* ************
*************************************************
<form id="form1" runat="server">
<div>
<asp:ListBox ID="_lbBox" runat="server" Height="100px" Width="100px">
<asp:ListItem Value="1" Text="One" />
<asp:ListItem Value="2" Text="Two" />
<asp:ListItem Value="3" Text="Three" />
<asp:ListItem Value="4" Text="Four" />
</asp:ListBox>
<asp:ListBox ID="_lbBox0" runat="server" ondblClick="RequestNoteSubjectSelectListbox_DoubleClick(this)"
Height="100px" Width="100px">
<asp:ListItem>vvvv</asp:ListItem>
</asp:ListBox>
</div>
</form>
抱歉抱歉抱歉
----
ondblClick =RequestNoteSubjectSelectListbox_DoubleClick(this)
----
i忘记删除此代码之前将解决方案放在此处...
im抱歉
thanx博士...看到这个..
现在已完成
sorry sorry sorry
----
ondblClick="RequestNoteSubjectSelectListbox_DoubleClick(this)"
----
i forgot to remove this code before put solution here...
i m sorry
thanx dr...for see this..
now its complete
这篇关于两个列表框的javascript(将所选项目从第一个列表框移动到第二个列表框)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文