Deselect all options in Multiple Select with 1 option

Posted by Shaded on Stack Overflow See other posts from Stack Overflow or by Shaded
Published on 2010-04-05T20:24:22Z Indexed on 2010/04/05 21:33 UTC
Read the original article Hit count: 139

Hello,

I currently have the following js code

function clearMulti(option)
{
    var i;
    var select = document.getElementById(option.parentNode.id);
    for(i=1;i<select.options.length;i++)
         {
        select.options[i].selected=false;
    }
}

and

function clearAllOpt(select)
{
    select.options[0].selected = false;
}

The first one deselects all options in the multiple select when called and the second clears the first option whenever anything else is selected.

The need for this is that the first option is for All.

This all works fine and dandy in FF, but in IE8 nothing happens... any suggestions on how to get this to work in both?

Thanks in advance.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about html