Forcing drop-down list to appear

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

    #1

    Forcing drop-down list to appear

    I apologize in advance for the cross-post (from
    microsoft.publi c.inetexplorer. scripting), but that board seems dead.

    I have what I think is a fairly simple problem, but I cannot figure
    this out. I have a SELECT object on my page. When the user performs
    a certain action, I want the focus to be placed in the drop-down field
    AND the actual list of drop-down objects to appear (i.e. simulating
    that the user has clicked in that field). Ideally, of course, the
    currently selected entry should be highlighted. Listed below is a
    snippet of sample code. If the focus is currently in the text field
    and the user clicks on the "Test" button, I would like the entire
    drop-down menu to appear. I have not had any success with the
    "fireEvent" method or the "click" method (only "focus" seems to work).

    Any help would be greatly appreciated. Thanks in advance.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
    <BODY>

    <SCRIPT LANGUAGE="Javas cript1.2">

    function displayDropDown () {
    fooObj = eval("document. Form.FooComboBo x");
    fooObj.focus();
    fooObj.click();
    //fooObj.fireEven t("onfocus");
    //fooObj.fireEven t("onclick");
    } //displayDropDown

    </SCRIPT>

    <FORM method="POST" Name="Form" AUTOCOMPLETE="O FF">
    <TABLE>
    <TR>
    <TD>
    <SELECT name="FooComboB ox">
    <OPTION VALUE="foo1" SELECTED>foo1</OPTION>
    <OPTION VALUE="foo2">fo o2</OPTION>
    <OPTION VALUE="foo3">fo o3</OPTION>
    </TD>
    </TR>

    <TR>
    <TD>
    <INPUT type="test" name="FooTextFi eld" value="">
    </TD>
    </TR>

    <TR>
    <TD>
    <INPUT type="Button" name="FooButton " value="Test" ENABLED
    onClick="displa yDropDown()">
    </TD>
    </TR>
    </FORM>
    </BODY>
    </HTML>
  • Grant Wagner

    #2
    Re: Forcing drop-down list to appear

    ehm wrote:
    [color=blue]
    > I apologize in advance for the cross-post (from
    > microsoft.publi c.inetexplorer. scripting), but that board seems dead.
    >
    > I have what I think is a fairly simple problem, but I cannot figure
    > this out. I have a SELECT object on my page. When the user performs
    > a certain action, I want the focus to be placed in the drop-down field
    > AND the actual list of drop-down objects to appear (i.e. simulating
    > that the user has clicked in that field).[/color]

    You can't programmaticall y make a <select> open.

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

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


    * 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


    Comment

    Working...