Select All in Javascript (Firefox extension) not working right

Posted by leezer3 on Stack Overflow See other posts from Stack Overflow or by leezer3
Published on 2010-05-16T21:54:27Z Indexed on 2010/05/16 22:00 UTC
Read the original article Hit count: 154

I'm having some problems with a select all/ none function. (I didn't write it, I'm trying to fix it!) It currently looks like this:

rsfindmod.SelAll = function(){
    document.getElementById("ListBox").selectAll();
    document.getElementById("ListBox").focus();
}

It's being used on a dynamically generated set of links, so there's no set number of items in this listbox. This seems to work most of the time, but randomly it only selects those which are visible at the time. Scrolling the list or hitting the button again seems to normally make it work as expected.

My first (Obvious?) thought was to replace the function entirely with the one from this link for testing: http://viralpatel.net/blogs/2009/06/listbox-select-all-move-left-right-up-down-javascript.html

Trouble is that I can't get this one to work whatsoever! This gives me the error that

listbox.options is not defined

Any thoughts please? I'm by no means certain whether it's the original function at fault, or something in the generation of this listbox.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about firefox-extension