Results 1 to 5 of 5

Thread: A simple question, I think...

  1. #1

    Thread Starter
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Question A simple question, I think...

    Hi again!

    I wanted to know how to set the focus to a specific textbox when an ASP page opens. I have an ASP that, when it is loaded, the cursor/focus is not on the textbox. I need for it to be. Any ideas?

    Thanks in advance.
    -vbuser1976
    VB6 Enterprise SP6
    SQL 7.0 SP2
    VBScript, HTML, Javascript, C++, a little UNIX

  2. #2
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    you do it in javascript

    document.yourFormName.yourTextName.focus();

  3. #3

    Thread Starter
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Question Stupid question, but need to know...

    where do I put this line of code??? Do I have to create a function or what do I have to do?
    -vbuser1976
    VB6 Enterprise SP6
    SQL 7.0 SP2
    VBScript, HTML, Javascript, C++, a little UNIX

  4. #4
    Addicted Member Michael Woolsey's Avatar
    Join Date
    Nov 2000
    Location
    Calgary, Alberta, Canada.
    Posts
    243
    You can also do it in VBScript, but that is only IE specific, unless they made Netscape better recently.

    VB Code:
    1. <body onLoad="txtField1.focus()">
    This should work for both javascript and vbscript... this will when the form loads, set the focus to txtField1 on your html/asp page.

    You may need to specify the form name if you are using a form on your page. For example:
    VB Code:
    1. <body onLoad="form1.txtField1.focus()">
    Hope it helps.
    Michael
    Application/Web Developer

    Visual Basic 6.0 SP5
    Active Server Pages
    Oracle 9i
    - I'm going to live forever, or die trying!

  5. #5

    Thread Starter
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Thumbs up THANX!

    Thank you, Michael & Sebs. Michael, the second line of code:
    Code:
    <body onLoad="form1.txtField1.focus()">
    is the one that worked.

    Thanks to you both for your input.
    -vbuser1976
    VB6 Enterprise SP6
    SQL 7.0 SP2
    VBScript, HTML, Javascript, C++, a little UNIX

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width