Olive,

The following function is one I use to achieve this effect:

/** Moves highlighted <option> elements between listboxes.
* @param from The ID of the listbox to move selections from.
* @param to The ID of the listbox to move the selections to.
*/
function MoveOptions(from, to)
{
   var destination = $("#"+to)[0];

   $("#"+from+" option:selected").each(function()
   {
      $(this)
         .attr('selected', false)
         .appendTo(destination);
   });
}


You can then use it with the following:

<select id='select1' multiple='multiple' size='6'
ondblclick="MoveOptions('select1', 'select2')">
   <option>Item 1</option><option>Item 2</option><option>Item
3</option><option>Item 4</option>
</select>

<a href='javascript:MoveOptions("select1", "select2")'>--&gt;</a>

<a href='javascript:MoveOptions("select2", "select1")'>&lt;--</a>

<select id='select2' multiple='multiple' size='6'
ondblclick="MoveOptions('select2', 'select1')">
</select>


It's a bit ugly but it's not much effort to get it looking nice. Bear in
mind that <option> elements are not sorted in any way when transferred from
one box to the other.

--rob


On 5/30/07, Olive <[EMAIL PROTECTED]> wrote:


Hi,

I did not find any plugin that would convert a "select multiple" box
into 2 "select multiple"
with the ability to move an item from the one to the other by clicking
on an item.

Do you have such function or any clue on how to achieve that ?

I have tried hard by creating a second list which contains the
selected item(s) and by hiding (option.css("display","none")) them in
the original one,
but I did not succeed in selecting the item in the original list
without unselecting the ones that are already selected.

It seems that nothing happens when I do
option.attr("selected","selected") or option.select().

Any idea ?

Olive.




--
Rob Desbois
Eml: [EMAIL PROTECTED]
Tel: 01452 760631
Mob: 07946 705987
"There's a whale there's a whale there's a whale fish" he cried, and the
whale was in full view.
...Then ooh welcome. Ahhh. Ooh mug welcome.

Reply via email to