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

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

P: n/a
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
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Rod Early wrote:
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 <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_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-deve...upgrade_2.html
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.