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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rod Early

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

    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
  • Grant Wagner

    #2
    Re: Detecting when the select element's dropdown list is open and/orclosed

    Rod Early wrote:
    [color=blue]
    > 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[/color]

    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.mySel ect.options[this.form.mySel ect.selectedInd ex].value);"
    />

    --
    | Grant Wagner <gwagner@agrico reunited.com>

    * Client-side Javascript and Netscape 4 DOM Reference available at:
    *


    * Internet Explorer DOM Reference available at:
    *
    Gain technical skills through documentation and training, earn certifications and connect with the community


    * 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


    Comment

    Working...