Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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.

share|improve this question
be specific about your requirement..!! what are you asking ? – Paresh Balar Mar 28 '12 at 7:03
A 45% accept rate with 70 questions isn't great. You'll probably get more help if you accept answers for some of your other questions. – njr101 Mar 28 '12 at 7:05
The demo you gave is working. What is it that you are looking for? – Starx Mar 28 '12 at 7:12

2 Answers

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");
        });
    });
});​
share|improve this answer

why not add button2 and do like

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.