[Javascript] Fw: Current value on multiple select

john saylor js0000 at gmail.com
Tue Nov 20 08:49:58 CST 2007


hey

On 11/20/07, Michael Borchers <list at tridemail.de> wrote:
> I have a multiple select <select name="foo[]" onclick="showCurrent()">

the select tag also needs the multiple="multiple" attribute set.

> The idea is to select multiple options by clicking (adding or removing with
> using CTRL key or whatever) but making the function showCurrent alert only
> the value I just clicked on.

i think you need a persistent data structure [array]. just populate it
with the values that have been selected. then compare with what is
selected to find the new value. you will also need to maintain this
data structure on each click.

you may also be able to use the selectedIndex property of the select
DOM object, but i do not think that this will give you what you want.
also, it may be implemented differently on different browsers [imagine
that!].

good luck.

-- 
\js  [ http://or8.net/~johns/ ]



More information about the Javascript mailing list