select bug in IE

J

JonQuark

Hi

I'm trying to dynamically add content to a select box when it is
clicked (because the app that I am developing contains many, many
select boxes with huge lists that are just way too slow to populate on
page load).

I have written code that works fine in gecko based browsers but in
Internet Explorer 6 after the select is populated, it is resized and
the popup is closed before the user can select an option. I have tried
returning false from onmousedown/onmouseup/onclick if the select is not
yet populated, I have tried setting a timeout to call the Click()
method (or the onclick/onmouseup/onmousedown method) if it isn't
populated but I can't seem to stop the popup list disappearing in IE6.

Any ideas appreciated.
(Stripped-down example code follows)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Select Bug TestBed</title>
<script>
function LazyPopulate(elem)
{
if(elem.populated == null)
{
//Copy the list items across
for(var j = 1 ; j < 10 ; j++)
{
elem.options[j]=new Option("new"+j, "value"+j);
}
elem.populated=true;
}
}
</script>
</head>
<body>
<select id="sel" onclick="LazyPopulate(this);">
<option>first</option>
</select>
</body>
</html>
 
R

RobB

JonQuark said:
Hi

I'm trying to dynamically add content to a select box when it is
clicked (because the app that I am developing contains many, many
select boxes with huge lists that are just way too slow to populate on
page load).

I have written code that works fine in gecko based browsers but in
Internet Explorer 6 after the select is populated, it is resized and
the popup is closed before the user can select an option. I have tried
returning false from onmousedown/onmouseup/onclick if the select is not
yet populated, I have tried setting a timeout to call the Click()
method (or the onclick/onmouseup/onmousedown method) if it isn't
populated but I can't seem to stop the popup list disappearing in IE6.

Any ideas appreciated.
(Stripped-down example code follows)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Select Bug TestBed</title>
<script>
function LazyPopulate(elem)
{
if(elem.populated == null)
{
//Copy the list items across
for(var j = 1 ; j < 10 ; j++)
{
elem.options[j]=new Option("new"+j, "value"+j);
}
elem.populated=true;
}
}
</script>
</head>
<body>
<select id="sel" onclick="LazyPopulate(this);">
<option>first</option>
</select>
</body>
</html>

You mentioned 'popup', as in...'popup window'? Unclear.

Try the onfocus handler instead. How 'huge' are we talking here? #:=0
 
J

JonQuark

Hi Rob,
You mentioned 'popup', as in...'popup window'? Unclear.
I mean that when you click on a select box, a list of options "pops
up", if you dynamically change the list of options in the
onclick/onmousedown handler, IE (But not Firefox) closes this list of
options (try the example HTML at the top of this thread if I'm still
being unclear)
Try the onfocus handler instead.
Thanks for the suggestion but if the lazypopulate() routine is called
there, IE still closes the options-list.

How 'huge' are we talking here? #:=0
It's a big Intranet app for an internal project, we have a lot of data
on a page, normally
there are maybe 20 or 30 selects on a page each with a maximum of 20
or 30 options. However it is the edge cases that make this
lazypopulate() so attractive.
It is possible to have hundreds of selects on a page with some of them
having a few hundred options. In testing it is very slow, but as the
user only wants to alter a few of these selects the lazypopulate fixes
it. In Gecko browsers now, we have an increasingly slick front-end but
we can't stipulate W3C compliant browsers only for this project
unfortunately.

Any other thoughts or ideas appreciated.

Jon.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top