Results 1 to 3 of 3

Thread: Defaulting Cursor on Web Page

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2000
    Location
    UK
    Posts
    36

    Defaulting Cursor on Web Page

    I have a asp page with multiple text boxes on and want the cursor to automatically be put into any one of these when the user browses to the page.

    Please can anyone help! My javascript knowledge is poo!!!

  2. #2
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    Heres a quick example...

    Code:
    <html>
    <head>
    <title>Set Focus Example</title>
    </head>
    <body onload="document.form1.text1.focus()">
    <form name="form1">
      <input type="text" name="text1">
      <input type="text" name="text2">
      <input type="text" name="text3">
    </form>
    </body>
    </html>
    document.form1.text1.focus() sets the default focus of a text box. It works like this...

    document tells javascript to work on the current document (always have this)
    form1 is the name of the form where the text boxes are situated. In my example its form1 (where it says <form name="form1">)
    text1 is the name of the text box you want default focus. In my example its text1 but it could easily be text2 or text3
    focus() sets focus to it

    If you want this to work you have to remember to give the form and text boxes a name attribute.

    Hope this helps
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2000
    Location
    UK
    Posts
    36
    That is great many thanks for a speedy reply!

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