|
 |
asptoday_discuss thread: setfocus to textbox
Message #1 by "Tan Chye Ting" <chyeting18@h...> on Thu, 27 Dec 2001 04:06:17
|
|
this might sound easy for you all,but hiow to set the cursor to a textbos
when i load the page...thanx..
Message #2 by "Joe Hughes" <JoeHughes@M...> on Thu, 27 Dec 2001 08:50:53 -0000
|
|
This should do it;
--------------------------------------------
<html>
<head>
<script language=javascript>
function textboxfocus() {
document.formname.textboxname.focus()
}
</script>
</head>
<body onload="textboxfocus()">
<form name=formname>
<input type=text name=textboxname>
</form>
</body>
</html>
--------------------------------------------
----- Original Message -----
From: "Tan Chye Ting" <chyeting18@h...>
To: "ASPToday Discuss" <asptoday_discuss@p...>
Sent: Thursday, December 27, 2001 4:06 AM
Subject: [asptoday_discuss] setfocus to textbox
> this might sound easy for you all,but hiow to set the cursor to a textbos
> when i load the page...thanx..
Message #3 by "N. Rajavelu" <nrajavelu@q...> on Thu, 27 Dec 2001 14:23:32 +0530
|
|
even simpler as
<body onload="formname.textboxname.focus()">
-----Original Message-----
From: Joe Hughes [mailto:JoeHughes@M...]
Sent: Thursday, December 27, 2001 2:21 PM
To: ASPToday Discuss
Subject: [asptoday_discuss] Re: setfocus to textbox
This should do it;
--------------------------------------------
<html>
<head>
<script language=javascript>
function textboxfocus() {
document.formname.textboxname.focus()
}
</script>
</head>
<body onload="textboxfocus()">
<form name=formname>
<input type=text name=textboxname>
</form>
</body>
</html>
--------------------------------------------
----- Original Message -----
From: "Tan Chye Ting" <chyeting18@h...>
To: "ASPToday Discuss" <asptoday_discuss@p...>
Sent: Thursday, December 27, 2001 4:06 AM
Subject: [asptoday_discuss] setfocus to textbox
> this might sound easy for you all,but hiow to set the cursor to a textbos
> when i load the page...thanx..
Message #4 by "Boni Gopalan" <boni@h...> on Fri, 28 Dec 2001 09:01:29 -0500
|
|
> This is not a straight forward question. You can do it, and yes a lot of
> people do it too.
>
> Read the following code snippet to understand how it is done.
>
> <html>
> <head>
> <title>My Page</title>
> <script>
> <!--
> function setFocus() {
> document.my_form.input_box.focus();
> }
> // --></script>
> </head>
> <body bgcolor="#ffffff" text="#000000" onLoad="setFocus()">
> <form action="<i>action URL</i>" name="my_form">
> The focus will go to this text input box: <input type="text"
> name="input_box">
> </form>
> </body>
> </html>
>
> thank you
> bONI
>
> ----- Original Message -----
> > From: "Tan Chye Ting" <chyeting18@h...>
> > To: "ASPToday Discuss" <asptoday_discuss@p...>
> > Sent: Thursday, December 27, 2001 4:06 AM
> > Subject: [asptoday_discuss] setfocus to textbox
> >
> >
> > > this might sound easy for you all,but hiow to set the cursor to a
> textbos
> > > when i load the page...thanx..
> > >
> >
>
Message #5 by "Louis T Kklauder Jr" <lklauder@w...> on Thu, 27 Dec 2001 17:11:00 -0500
|
|
Hi Tan;
Here is some sample DHTML Jscript code that you might be able to use as
a pattern for what you want:
<HEAD>
<% Response.CacheControl = "no-cache"; %>
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript (ECMAScript)"
name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<script event="onload()" for="window">
// following is per tip from Leena Natekar via Wrox,
aspx_professional
if ( document.all["ddown_user_role_name"] == null )
{
// tbox_html_server_name is an html text box
// with runat="server" so that its value can be accessed
// in serverside code and is an html control rather than
// an web_form (<asp: ) control so that it is a member
// of Page_login from the point of view of JavaScript and
// has the .focus() method. Therefore could use:
// Page_login.tbox_html_server_name.focus() ;
// However, for consistency, instead use
document.all["tbox_user_id"].focus("true") ;
}
else
{
// ddown_user_role_name is a web_form dropdown
// list to avoid the unpleasantness of dealing with html
// select controls. It is not a member of Page_login and
// does not take the DHTML .focus() method; mercifully there
// is the document.all.
document.all["ddown_user_role_name"].focus("true") ;
}
// alert("onload script was run") ;
</script>
</HEAD>
Lou Klauder
-----Original Message-----
From: Tan Chye Ting [mailto:chyeting18@h...]
Sent: Thursday, December 27, 2001 4:06 AM
To: ASPToday Discuss
Subject: [asptoday_discuss] setfocus to textbox
this might sound easy for you all,but hiow to set the cursor to a
textbos
when i load the page...thanx..
|
|
 |