Results 1 to 3 of 3

Thread: Submit page when an image becomes focused

  1. #1

    Thread Starter
    Hyperactive Member MarkusJ_NZ's Avatar
    Join Date
    Jun 2001
    Posts
    375

    Submit page when an image becomes focused

    Hi, I have a image and I want the current page to get submitted when a user tabs to the image.

    I thought that I could just go;
    <img src="./someimage.gif" onFocus="javascript: document.form1.submit()">

    but it does not work..

    Any ideas would be appreciated

    Thanks
    MarkusJ

  2. #2
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    India
    Posts
    276
    What you have done is correct, Mark. Jus that you missed the TabIndex Attribute.

    Get this:
    <img src="c:/pump.gif" tabindex=2 onfocus="javascript:document.myForm.submit()">

    By default an image tag wouldn't get focus. For such elements we need to add the TabIndex attribute and specify the Index.

    - Jemima.

  3. #3
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    Nice catch, Jemina.

    But Markus, why do you want to submit a form when an image gets focus? What if the user was tabbing to something past that image, wanted to enter a value else where or submit a different form on the page, or he was wanting to select an anchor on the page?

    I guess if there are no anchors, no inputs, and only one "trigger" picture on the page, then it makes some sense.
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

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