Click to See Complete Forum and Search --> : setting focus to a drop down list


rahulvasanth
November 9th, 2005, 04:29 AM
Hi

I want to set focus to a drop down list in my web page. But I m not able to do it. The focus() is not available for the drop down list. Is there any other way to set focus to a drop down list ? other than focus()

Thanking in advance ?

Shuja Ali
November 9th, 2005, 04:52 AM
Hi

I want to set focus to a drop down list in my web page. But I m not able to do it. The focus() is not available for the drop down list. Is there any other way to set focus to a drop down list ? other than focus()

Thanking in advance ?
You can use Clientside JavaScript code to do that.

rahulvasanth
November 9th, 2005, 05:14 AM
I m very much new to .NET and JAVA.

Can u provide a sample of the javascript.

Thankning in advance

Shuja Ali
November 9th, 2005, 05:36 AM
I m very much new to .NET and JAVA.

Can u provide a sample of the javascript.

Thankning in advance
You should take a look at some Javascript tutorials. And how to interact with .NET using Javascript in ASP.NET.

HanneSThEGreaT
November 9th, 2005, 07:02 AM
Can u provide a sample of the javascript.


This may be useful to you!!
<%@ Language=JavaScript%>
<%Response.buffer=true%>
<html>

<head>
<title>Example Focus</title>
<SCRIPT LANGUAGE="JavaScript">
<!--
function SetFocus() // function to set focus
{
frmExample.txtStudentName.focus()
}
//-->
</SCRIPT>
</head>

<body>

<h1 align="center">Focus Example</h1>

<form id="frmExample" name="frmExample"method="post">

<center><H3>Student Information</H3>
<p>Student name: <input id="txtStudentName" name="txtStudentName" size="50"><br>
<INPUT TYPE="button" VALUE="Set Focus" onClick="SetFocus()">
</center>
</form>

</body>
</html>
NOTE:
I have done this using Notepad
Save this code as Anything as long as you include an .asp extension

Hope this helps!

rahulvasanth
November 9th, 2005, 10:25 PM
IT'S WORKING ........!!!!!

Thanks a lot

HanneSThEGreaT
November 9th, 2005, 11:55 PM
No problem buddy!

Just for interest sake, you could use something like:
<SELECT NAME="Airline">

<OPTION VALUE="American">American Airlines
<OPTION VALUE="United">United Airlines
<OPTION VALUE="USAir">USAIR
<OPTION VALUE="Delta">Delta Airlines
<OPTION VALUE="BritAir">British Airways
<OPTION VALUE="NWAir">Northwest Airlines

</SELECT>
To get a dropdown list in HTML. The Option Values are the "names" of the listitems and the display values.

Good work!