Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery moving MultiSelect values to another MultiSelect

Tags:

So I have a MultiSelect box with x values which I need the ability to move to another MultiSelect box and vise versa.

<select class="boxa" multiple="multiple">   <option value="volvo">Volvo</option>   <option value="saab">Saab</option>   <option value="mercedes">Mercedes</option>   <option value="audi">Audi</option> </select>  <select class="boxb" multiple="multiple">  </select> 

Need to move all or one of the values of boxa to boxb on a button click, also with the ability to move the values back from boxb to boxa.

Does jQuery have anything like this or is this a custom snippet of code?

like image 281
Phill Pafford Avatar asked Jun 29 '09 14:06

Phill Pafford


1 Answers

$().ready(function() {    $('#add').click(function() {     return !$('#select1 option:selected').remove().appendTo('#select2');    });    $('#remove').click(function() {     return !$('#select2 option:selected').remove().appendTo('#select1');    });   }); 
like image 132
Yasitha Avatar answered Oct 05 '22 19:10

Yasitha