views:

330

answers:

1

Hey folks,

I have a listbox containing "all" the items and a second listbox that will contain "selected" items. I want to have it so that double-clicking an item in the "all" listbox adds that item to the "included" listbox.

Currently i have :

$(document).ready(function()
{
    $('#AllAirlines option').dblclick(AddAirline);
}

function AddAirline() 
{
    $('#AllAirlines option:selected').remove().appendTo('#AirlineList');
}

Which works fine in FireFox... but in IE8 etc, fails. Any ideas why?

A: 

Here is a slightly updated version that also works in IE8 - it just doesn't like the event hook up... and you also forgot to close your document-ready...

$(document).ready(function()
{
    $('#AllAirlines').dblclick(function() { AddAirline(); });
});

function AddAirline() 
{
    $('#AllAirlines option:selected').remove().appendTo('#AirlineList');
}
Sohnee
Thanks, that worked great.I did have teh closing parenthesis on the document.ready by the way... it was bad copy/pasting not bad coding ;)
krisg
I'm glad it helped - it would be great if your could mark the answer (hit that tick over on the left!)
Sohnee
Oops my bad. I guess i got caught up in the excitement =P
krisg
No worries! Cheers
Sohnee