469,267 Members | 1,643 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,267 developers. It's quick & easy.

cursor in position

When a page is opened is there a way to set focus of the cursor to a named
input.
I want the cursor to be in the input box when the page is opened.
Thanks
Jul 19 '05 #1
6 3709
Using client-side script, not ASP, you can.

<body onload="document.nameofform.nameofinput.focus();">

Ray at work

"Gonzosez" <tb***@hinklemfgNS.com> wrote in message
news:OA**************@TK2MSFTNGP11.phx.gbl...
When a page is opened is there a way to set focus of the cursor to a named
input.
I want the cursor to be in the input box when the page is opened.
Thanks

Jul 19 '05 #2
Gonzosez wrote:
When a page is opened is there a way to set focus of the cursor to a
named input.
I want the cursor to be in the input box when the page is opened.
Thanks


This is a client-side coding question which is off-topic for this newsgroup
(ASP is server-side technology). In the future please direct your
client-side questions to a newsgroup with DHTML in its name, or to one of
the microsoft.pyoblic.scripting newsgroups.

To answer your question, set the id property of the input and then put the
following line of code in the window_onload event:

inputid.focus

HTH,
Bob Barrows

Jul 19 '05 #3
Gazing into my crystal ball I observed "Gonzosez" <tb***@hinklemfgNS.com>
writing in news:OA**************@TK2MSFTNGP11.phx.gbl:
When a page is opened is there a way to set focus of the cursor to a
named input.
I want the cursor to be in the input box when the page is opened.
Thanks


You might want to think twice about wanting to do this. If someone is on a
slow connection, and the page has partially loaded, they might start
filling out the form, get two fields completed, then suddenly, they are
back to field 1, but they are still typing info for field 3.

--
Adrienne Boswell
Please respond to the group so others can share
http://www.arbpen.com
Jul 19 '05 #4
Good point. My web banking login page does that, and not only does it set
focus, it also executes a form.reset(); which irritates me beyond belief.
I'm on a fast connection, but their servers are ungodly slow. They have 7
NT servers for 630 banks. Unacceptable.

Ray at work

"Adrienne" <ar****@sbcglobal.net> wrote in message
news:Xn****************************@207.115.63.158 ...
Gazing into my crystal ball I observed "Gonzosez" <tb***@hinklemfgNS.com>
writing in news:OA**************@TK2MSFTNGP11.phx.gbl:
When a page is opened is there a way to set focus of the cursor to a
named input.
I want the cursor to be in the input box when the page is opened.
Thanks
You might want to think twice about wanting to do this. If someone is on

a slow connection, and the page has partially loaded, they might start
filling out the form, get two fields completed, then suddenly, they are
back to field 1, but they are still typing info for field 3.

--
Adrienne Boswell
Please respond to the group so others can share
http://www.arbpen.com

Jul 19 '05 #5
It is possible to escape that one.
Put the form in a layer that is set to not visible.
After the page has loaded set the layer to visible again.

Meindert, MCP
When a page is opened is there a way to set focus of the cursor to a
named input.
I want the cursor to be in the input box when the page is opened.
Thanks
You might want to think twice about wanting to do this. If someone is on

a slow connection, and the page has partially loaded, they might start
filling out the form, get two fields completed, then suddenly, they are
back to field 1, but they are still typing info for field 3.


Jul 19 '05 #6
I get this a lot in a web application I've written for my company. Just
about EVERY page is some sort of data entry page, and (of course) everyone
wants the focus placed when the page loads.

I get around this by putting all of my javascript at the END of the page,
rather than in the <head> section, with the last line of script being the
..focus() line. That way, the page and all of its elements have completely
loaded before any client-side instructions are executed. This has the added
benefit of cutting way way back on "object required" and "not found" errors.

Some of the pages are huge, and involve mind-numbingly lengthy client-side
validation scripts. When I inherited the application, those scripts were
scattered all over the page. What I do now is declare a server-side array
at the top of the page, adding the client-side function code to it as the
page builds (each element gets a function or discrete instruction), then as
a last step write the SCRIPT tag, loop the array writing all the javascript,
then close the script.

- Wm "It may be wrong but you wanted it fast" Morris

--
William Morris
Product Development, Seritas LLC

"Adrienne" <ar****@sbcglobal.net> wrote in message
news:Xn****************************@207.115.63.158 ...
Gazing into my crystal ball I observed "Gonzosez" <tb***@hinklemfgNS.com>
writing in news:OA**************@TK2MSFTNGP11.phx.gbl:
When a page is opened is there a way to set focus of the cursor to a
named input.
I want the cursor to be in the input box when the page is opened.
Thanks
You might want to think twice about wanting to do this. If someone is on

a slow connection, and the page has partially loaded, they might start
filling out the form, get two fields completed, then suddenly, they are
back to field 1, but they are still typing info for field 3.

--
Adrienne Boswell
Please respond to the group so others can share
http://www.arbpen.com

Jul 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Dan H. | last post: by
1 post views Thread by Tantra Veda | last post: by
1 post views Thread by objectref | last post: by
1 post views Thread by Paul | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.