cursor in position

G

Gonzosez

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
 
R

Ray at

Using client-side script, not ASP, you can.

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

Ray at work
 
B

Bob Barrows

Gonzosez said:
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
 
A

Adrienne

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

Ray at

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
 
P

PB4FUN

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
 
W

WIlliam Morris

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
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top