Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
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
Posted

did it...complete works...

XML
<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>

*************************************************
XML
<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>
 
Share this answer
 
Comments
Your code looks wrong. You are calling RequestNoteSubjectSelectListbox_DoubleClick ondblClick, but there is no such function in JavaScript defined. You have lstDblClicked and lstDblClicked1, which are not invoked. So, please correct the code.
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
 
Share this answer
 
Comments
BillW33 27-Apr-15 10:50am    
You should not post a comment to a solution or an addition to your question/solution as a "Solution". Either add a comment to a previous solution by pressing the "Have a Question or Comment?" button or update your question by using the "Improve question" button. I thought you should know why this might get downvoted.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900