In case anyone else is coming across this issue, for some reason, when attempting to select all options in a multi-select “<select>” box, for some reason, IE doesn’t work the first time through my iteration. Here is more:

IE Select Bug

WORKAROUND

Don’t set Multiple immediately before selecting options

Alright, I found it - for some reason, when you use javascript to set the “multiple=true”, you cannot then immediately set selected=’true’. It just doesn’t work in Internet Explorer. (Or at least we couldn’t get it to work - please let us know if you find another solution).

The Old Function

function selectAll(selector){
if(!selector)alert('Selector doesnt exist');
else{
selector.multiple=true;
for(var i=0;i
selector.options[i].selected = true;
}
return false;
}
}

The New

function selectAll(selector){
if(!selector)alert('Selector doesnt exist');
else{
/**selector.multiple=true; Call this far in advance, or have it already set to “multiple”**/
for(var i=0;i
selector.options[i].selected = true;
}
return false;
}
}

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Slashdot
  • StumbleUpon
  • Technorati
  • YahooMyWeb

Leave a Reply

You must be logged in to post a comment.