Detecting when the select element's dropdown list is open and/or closed

R

Rod Early

I need to know when the select element's dropdown list is opened (as
when the user clicks on the arrow or does ALT-downarrow from the
keyboard). Similarly, I need to known when the dropdown list closes.

The closing of the dropdown list can happen without changing the
dropdown, hence the onchange event is not a sure way to determine that
the dropdown list closed.

Is this possible in Internet Explorer?

Thanks,
Rod
 
G

Grant Wagner

Rod said:
I need to know when the select element's dropdown list is opened (as
when the user clicks on the arrow or does ALT-downarrow from the
keyboard). Similarly, I need to known when the dropdown list closes.

The closing of the dropdown list can happen without changing the
dropdown, hence the onchange event is not a sure way to determine that
the dropdown list closed.

Is this possible in Internet Explorer?

Thanks,
Rod

You only think you need to know when the drop-down list closes.

The drop-down list closes when some other element on the page receives
focus. So, trap focus on the item that the user is going to click after
selecting something from the drop-down menu:

<select name="mySelect">
<option value="1">One</option>
<!-- etc -->
</select>
<input type="button" name="myButton"
onclick="alert('The drop-down menu has closed, the value is ' +
this.form.mySelect.options[this.form.mySelect.selectedIndex].value);"
/>

--
| Grant Wagner <[email protected]>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-developer/upgrade_2.html
 

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
474,085
Messages
2,570,597
Members
47,219
Latest member
Geraldine7

Latest Threads

Top