Abhishek
Abhishek

Reputation: 6900

Remove an option from html multi select using prototype js library

I want to remove an option from a HTML multi select box using prototype. I tried the one below, and unfortunately it did not work

$('left').options.item($('left').selectedIndex)).remove();

I found some example with .removedChild()..I did not want to use them as it defeats the purpose of using JS library like Prototype.

Upvotes: 1

Views: 3267

Answers (3)

Rudie
Rudie

Reputation: 53861

You could probably:

$('left').down(':selected').remove();

or :checked or :active or something. I assume.

edit Nope. Weird docs. http://api.prototypejs.org/dom/Element/select/

edit .select > .down. http://api.prototypejs.org/dom/Element/prototype/down/ Thanks @clockworkgeek

Upvotes: 1

ShankarSangoli
ShankarSangoli

Reputation: 69915

You are missing the quotes. Try this

$('left').options.item($('left').selectedIndex).remove();

Upvotes: 2

Abhishek
Abhishek

Reputation: 6900

I figured out that there was a bracket missing. The right line of code is,

$('left').options.item($('left').selectedIndex).remove();

Upvotes: 0

Related Questions