cursor in position

Discussion in 'ASP General' started by Gonzosez, Sep 19, 2003.

  1. Gonzosez

    Gonzosez Guest

    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
    Gonzosez, Sep 19, 2003
    #1
    1. Advertising

  2. Gonzosez

    Ray at Guest

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

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

    Ray at work

    "Gonzosez" <> wrote in message
    news:...
    > 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
    >
    >
    Ray at, Sep 19, 2003
    #2
    1. Advertising

  3. Gonzosez

    Bob Barrows Guest

    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
    Bob Barrows, Sep 19, 2003
    #3
  4. Gonzosez

    Adrienne Guest

    Gazing into my crystal ball I observed "Gonzosez" <>
    writing in news::

    > 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
    Adrienne, Sep 19, 2003
    #4
  5. Gonzosez

    Ray at Guest

    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" <> wrote in message
    news:Xns93FB709507A2Aarbpenyahoocom@207.115.63.158...
    > Gazing into my crystal ball I observed "Gonzosez" <>
    > writing in news::
    >
    > > 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
    Ray at, Sep 19, 2003
    #5
  6. Gonzosez

    PB4FUN Guest

    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.
    >
    PB4FUN, Sep 19, 2003
    #6
  7. 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" <> wrote in message
    news:Xns93FB709507A2Aarbpenyahoocom@207.115.63.158...
    > Gazing into my crystal ball I observed "Gonzosez" <>
    > writing in news::
    >
    > > 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
    WIlliam Morris, Sep 19, 2003
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt Tapia

    Insert text at cursor position

    Matt Tapia, Nov 26, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    532
    Chris Taylor
    Nov 26, 2003
  2. Matt Tapia

    Insert text at cursor position...still

    Matt Tapia, Dec 1, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    584
    General Protection Fault
    Dec 1, 2003
  3. =?Utf-8?B?VG9tYXMgS2VwaWM=?=

    Changing DEFAULT cursor to WAIT cursor in ASP

    =?Utf-8?B?VG9tYXMgS2VwaWM=?=, Apr 5, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    2,294
    Bruce Barker
    Apr 5, 2005
  4. invy
    Replies:
    4
    Views:
    380
    CBFalconer
    Dec 28, 2006
  5. dmaziuk
    Replies:
    3
    Views:
    554
    Chris Gonnerman
    Jan 25, 2011
Loading...

Share This Page