Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.focus()

Status
Not open for further replies.

Kendel

Programmer
Apr 24, 2002
1,512
US
Hello All,

Do you know how to set focus on a dropdown list?

This: document.form1.control.focus()
will work if the control is a textbox. If the control is a dropdown list, then it won't work.

Thanks.
 
Focus works fine even if it's a drop down. For eg..

<HTML>
<HEAD>
<META NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;>
<TITLE></TITLE>
<SCRIPT LANGUAGE=javascript>
<!--
function FocusMe()
{
document.test1.select1.focus();
}
-->

</SCRIPT>

</HEAD>
<BODY>
<form name=&quot;test1&quot; method=&quot;POST&quot; >
<SELECT id=select1 name=select1>
<OPTION> 1</OPTION>
<OPTION> 2</OPTION>

</SELECT>
<INPUT type=&quot;button&quot; value=&quot;Button&quot; id=button1 name=button1 onclick=&quot;javascript:FocusMe()&quot;>
</form>


</BODY>
</HTML>
 
But if you have the first entry is blank, you wouldn't see it but I think it is focused.

<form name=&quot;test1&quot; method=&quot;POST&quot; >
<SELECT id=select1 name=select1>
<OPTION> </OPTION>
<OPTION> 1</OPTION>
<OPTION> 2</OPTION>

</SELECT>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top