Connecting Tech Pros Worldwide Forums | Help | Site Map

Forcing drop-down list to appear

ehm
Guest
 
Posts: n/a
#1: Jul 20 '05
I apologize in advance for the cross-post (from
microsoft.public.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="Javascript1.2">

function displayDropDown() {
fooObj = eval("document.Form.FooComboBox");
fooObj.focus();
fooObj.click();
//fooObj.fireEvent("onfocus");
//fooObj.fireEvent("onclick");
} //displayDropDown

</SCRIPT>

<FORM method="POST" Name="Form" AUTOCOMPLETE="OFF">
<TABLE>
<TR>
<TD>
<SELECT name="FooComboBox">
<OPTION VALUE="foo1" SELECTED>foo1</OPTION>
<OPTION VALUE="foo2">foo2</OPTION>
<OPTION VALUE="foo3">foo3</OPTION>
</TD>
</TR>

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

<TR>
<TD>
<INPUT type="Button" name="FooButton" value="Test" ENABLED
onClick="displayDropDown()">
</TD>
</TR>
</FORM>
</BODY>
</HTML>
Grant Wagner
Guest
 
Posts: n/a
#2: Jul 20 '05

re: Forcing drop-down list to appear


ehm wrote:
[color=blue]
> I apologize in advance for the cross-post (from
> microsoft.public.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 programmatically make a <select> open.

--
| Grant Wagner <gwagner@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


Closed Thread


Similar JavaScript / Ajax / DHTML bytes