client-side onclick populates dropdown

J

John Grandy

I wrote a function to populate my dropdowns on the client-side.

The function adds <option> elements to the <select> only if none are
initially present.

I call the population function from either the onfocus or onclick event of
the <select> as follows :

onclick="populateDropdown(this);return true;"

It works in Firefox.

In IE, the dropdown is populated but the default handler for the click event
is not invoked, thus requiring the user to click the dropdown twice : once
to populate it and once to drop it down.

Does anyone know what is going on and a workaround for what appears to be an
IE bug ?
 
J

John A Grandy

What's the difference ?

Eliyahu Goldin said:
Why don't you just return true in populateDropdown and call it as
onclick="return populateDropdown(this)"?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


John Grandy said:
I wrote a function to populate my dropdowns on the client-side.

The function adds <option> elements to the <select> only if none are
initially present.

I call the population function from either the onfocus or onclick event
of the <select> as follows :

onclick="populateDropdown(this);return true;"

It works in Firefox.

In IE, the dropdown is populated but the default handler for the click
event is not invoked, thus requiring the user to click the dropdown twice
: once to populate it and once to drop it down.

Does anyone know what is going on and a workaround for what appears to be
an IE bug ?
 
G

Guest

John,

I would pre-populate the dropdowns before User clicks on them, say when the
page is loaded, but if you need to wait until User decides to use your
control, you can try to work around the IE issue by placing the following (or
similar) code in onmousemove event:
<select onmousemove='prePopulate(this)' ...

<script ...
function prePopulate(ddn){
if (ddn.options.length == 0)
// call your populate function:
populateDropdown(ddn);
}

it seems to be working fine for smaller lists (up to a few hundred items)

HTH

John A Grandy said:
What's the difference ?

Eliyahu Goldin said:
Why don't you just return true in populateDropdown and call it as
onclick="return populateDropdown(this)"?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


John Grandy said:
I wrote a function to populate my dropdowns on the client-side.

The function adds <option> elements to the <select> only if none are
initially present.

I call the population function from either the onfocus or onclick event
of the <select> as follows :

onclick="populateDropdown(this);return true;"

It works in Firefox.

In IE, the dropdown is populated but the default handler for the click
event is not invoked, thus requiring the user to click the dropdown twice
: once to populate it and once to drop it down.

Does anyone know what is going on and a workaround for what appears to be
an IE bug ?
 
J

John A Grandy

Hi Sergey and thanks for the response.

I have been using onmousedown , which works for IE7 and Firefox, but not
IE6.

Which browsers have you tested onmousemove with ?


Sergey Poberezovskiy said:
John,

I would pre-populate the dropdowns before User clicks on them, say when
the
page is loaded, but if you need to wait until User decides to use your
control, you can try to work around the IE issue by placing the following
(or
similar) code in onmousemove event:
<select onmousemove='prePopulate(this)' ...

<script ...
function prePopulate(ddn){
if (ddn.options.length == 0)
// call your populate function:
populateDropdown(ddn);
}

it seems to be working fine for smaller lists (up to a few hundred items)

HTH

John A Grandy said:
What's the difference ?

Eliyahu Goldin said:
Why don't you just return true in populateDropdown and call it as
onclick="return populateDropdown(this)"?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


"John Grandy" <johnagrandy-at-gmail-dot-com> wrote in message
I wrote a function to populate my dropdowns on the client-side.

The function adds <option> elements to the <select> only if none are
initially present.

I call the population function from either the onfocus or onclick
event
of the <select> as follows :

onclick="populateDropdown(this);return true;"

It works in Firefox.

In IE, the dropdown is populated but the default handler for the click
event is not invoked, thus requiring the user to click the dropdown
twice
: once to populate it and once to drop it down.

Does anyone know what is going on and a workaround for what appears to
be
an IE bug ?
 
G

Guest

John,

I was testing on IE6 - and on it onmousedown works the same as onclick -
that is why I used onmousemove - then it seems to work just fine.

John A Grandy said:
Hi Sergey and thanks for the response.

I have been using onmousedown , which works for IE7 and Firefox, but not
IE6.

Which browsers have you tested onmousemove with ?


Sergey Poberezovskiy said:
John,

I would pre-populate the dropdowns before User clicks on them, say when
the
page is loaded, but if you need to wait until User decides to use your
control, you can try to work around the IE issue by placing the following
(or
similar) code in onmousemove event:
<select onmousemove='prePopulate(this)' ...

<script ...
function prePopulate(ddn){
if (ddn.options.length == 0)
// call your populate function:
populateDropdown(ddn);
}

it seems to be working fine for smaller lists (up to a few hundred items)

HTH

John A Grandy said:
What's the difference ?

message Why don't you just return true in populateDropdown and call it as
onclick="return populateDropdown(this)"?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


"John Grandy" <johnagrandy-at-gmail-dot-com> wrote in message
I wrote a function to populate my dropdowns on the client-side.

The function adds <option> elements to the <select> only if none are
initially present.

I call the population function from either the onfocus or onclick
event
of the <select> as follows :

onclick="populateDropdown(this);return true;"

It works in Firefox.

In IE, the dropdown is populated but the default handler for the click
event is not invoked, thus requiring the user to click the dropdown
twice
: once to populate it and once to drop it down.

Does anyone know what is going on and a workaround for what appears to
be
an IE bug ?
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top