Fake submit button & return

Discussion in 'HTML' started by Ike, May 3, 2006.

  1. Ike

    Ike Guest

    I'm hoping someone can tell me how to do something which, though trivial to
    some, I'm really struggling with here. If I have an href, which, through the
    magic of CSS, we make appear as a button (a surrogate Submit button no
    less), I somehow need to make it pick up when "enter" ("return") is pressed,
    so that it acts like a real Submit button. In other words, I think somehow
    the href needs to pick up the focus, and if it HAS the focus, will it then
    act the same as if it were clicked upon? Below is the construction of the
    button, without the css:

    <div class="rvbuttons" style="padding-right:81px;" >
    <a href="javascript:document.frmLogin.submit();" align="left"
    class="rvbutton" style="float:center;" onClick="return
    chkLogin()">Submit</a>
    </div>

    TIA, Ike
     
    Ike, May 3, 2006
    #1
    1. Advertising

  2. Ike wrote:
    > I'm hoping someone can tell me how to do something which, though trivial to
    > some, I'm really struggling with here. If I have an href, which, through the
    > magic of CSS, we make appear as a button (a surrogate Submit button no
    > less), I somehow need to make it pick up when "enter" ("return") is pressed,
    > so that it acts like a real Submit button.


    So you want something that looks like a submit button and acts like a
    submit button - so why don't you use a submit button instead of messing
    around with JavaScript / CSS dependant modification of something
    designed to do something entirely different?
     
    David Dorward, May 3, 2006
    #2
    1. Advertising

  3. Ike

    Guest

    If I understand you right, you want your submit function to be
    triggered by pressing the enter key on the keyboard, right?

    Adding javascript to the page like this might be what you need:

    function fetchKey() {
    if (window.event.keyCode == 13) {
    // submit code in here
    }
    }

    document.onkeydown=fetchKey;

    So, when a key is entered, it checks to see if it's the enter key (13)
    and if it is, it does your submit. I'm also curious why you wouldn't
    just use a real submit button. If it has to be a get instead of a
    post, then just add the method="get" attribute to your form. Just
    guessing that that might be one reason why you would want a link
    instead of a button.
     
    , May 3, 2006
    #3
    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. Mark
    Replies:
    1
    Views:
    1,727
  2. Ghafran Abbas
    Replies:
    0
    Views:
    4,247
    Ghafran Abbas
    Oct 12, 2004
  3. Replies:
    2
    Views:
    2,515
    Joerg Jooss
    Nov 21, 2005
  4. Replies:
    2
    Views:
    6,269
  5. Fake Submit button

    , Jun 8, 2007, in forum: HTML
    Replies:
    26
    Views:
    1,943
    Jukka K. Korpela
    Jun 15, 2007
Loading...

Share This Page