By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,624 Members | 1,692 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,624 IT Pros & Developers. It's quick & easy.

select bug in IE

P: n/a
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>

Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
JonQuark wrote:
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

Jul 23 '05 #2

P: n/a
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.

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.