Results 1 to 5 of 5

Thread: Set focus

  1. #1
    Guest
    Can anyone let me know how to set focus to the first field on an Active server page?

    I guess the following code can be used

    theForm.fieldname.focus() 'java script

    can be used but I am not sure where to invoke this.


    Thanks.

  2. #2
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    I can't remember the JavaScript to do it, so I can't really comment on that statement. You could use VBScript though, I'm pretty sure, just use theFormName.fieldName.SetFocus.

    This is client-side, not server side, so you need to either add this code to the very end of the page, or put the code in a sub and call it whenever you need to. It shouldn't be that hard I think.
    Harry.

    "From one thing, know ten thousand things."

  3. #3
    Guest
    here is the code:

    function window_onload(theForm) {
    theForm.AppNum.focus();
    }

    If I add an alert message before and after the focus statement, i get just the first message. And it doesnt give me an error message.
    (By the way this is a client side script).

    IF this code should not be placed in the windows on load event, is there some other event where it can be placed. My only requirement is when the page is displayed, the first field should receive focus.


    Could anyone tell me whats wrong.
    Thanks.


  4. #4
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Perhaps the window_onload event occurs before the page is displayed, and the object AppNum hasn't been instantiated yet. Try adding the code to the end of the HTML if you can, see if that's any better.
    Harry.

    "From one thing, know ten thousand things."

  5. #5
    Guest
    Thanks Harry.

    Apparently if this is placed after the HTML code, it is executed even before windows onload.


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