4

I want move list box item to another list box. I searched and found this location.

http://jsfiddle.net/bdMAF/1/

This is exactly I want. But I want to remove the list box items. Is it possible? Please help me as needful.

Thanks.

2
  • be specific about your requirement..!! what are you asking ? Commented Mar 28, 2012 at 7:03
  • The demo you gave is working. What is it that you are looking for? Commented Mar 28, 2012 at 7:12

2 Answers 2

6

I presume you mean remove them from the second list and back to the first list. Try this http://jsfiddle.net/bdMAF/38/

<div>
    <h3>List A</h3>
    <select id="list1" multiple="multiple" rows=2>
        <option value=1>Option 1</option>
        <option value=2>Option 2</option>
        <option value=3>Option 3</option>
        <option value=4>Option 4</option>
    </select>
    <br/>
    <input id="button1" type="button" value="Move to List B" />
</div>
<div>
    <h3>List A</h3>
    <select id="list2" multiple="multiple" rows=2>        
    </select>
    <br/>
    <input id="button2" type="button" value="Move to List A" />
</div>

$(function(){
    $("#button1").click(function(){
        $("#list1 > option:selected").each(function(){
            $(this).remove().appendTo("#list2");
        });
    });

    $("#button2").click(function(){
        $("#list2 > option:selected").each(function(){
            $(this).remove().appendTo("#list1");
        });
    });
});​
Sign up to request clarification or add additional context in comments.

Comments

1

why not add button2 and do like

$(function(){
    $("#button2").click(function(){
        $("#list1 > option:selected").each(function(){
            $(this).remove();
        });
    });
});​

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.