Forcing drop-down list to appear

E

ehm

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>
 
G

Grant Wagner

ehm said:
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).

You can't programmatically make a <select> open.

--
| 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

Forum statistics

Threads
473,780
Messages
2,569,610
Members
45,255
Latest member
TopCryptoTwitterChannels

Latest Threads

Top