1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Possible to make a button that presses the enter key?

Discussion in 'HTML & JavaScript' started by MarketerX, Aug 27, 2010.

  1. MarketerX

    MarketerX Regular Member

    Joined:
    Mar 7, 2010
    Messages:
    398
    Likes Received:
    120
    Hey guys, title says everything. I want to make a submit button that "presses" the enter key on the keyboard to submit a form.

    I have my reasons for needing a button that does this, it's actually quite important that I figure this out..

    Anyone care to enlighten me here? I'm guessin its some JS code...?
     
  2. cyklotrial

    cyklotrial Regular Member

    Joined:
    Oct 13, 2008
    Messages:
    248
    Likes Received:
    82
    Location:
    Wonderland
    Add to button simple JS code for onclick event:
    Code:
    document.form_id.submit();
    
     
  3. MarketerX

    MarketerX Regular Member

    Joined:
    Mar 7, 2010
    Messages:
    398
    Likes Received:
    120
    Will this press the enter button? My button that I want to make is actually located on a different HTML page than my form. My form is within an iframe. Does this make sense??? :)

    Can i get the form ID from the iframed page and have my submit button work? I'm guessing no...
     
  4. cyklotrial

    cyklotrial Regular Member

    Joined:
    Oct 13, 2008
    Messages:
    248
    Likes Received:
    82
    Location:
    Wonderland
    If both sites are located in the same domain or you have acces to both sites sourcecodes - You can do that. If no - there is no way.
    OFC you can try clickjacking but it's illegal and we dont like illegal stuf :)
     
  5. seojumper

    seojumper Regular Member

    Joined:
    Jan 13, 2008
    Messages:
    233
    Likes Received:
    27
    How is clickjacking illegal?
     
  6. MarketerX

    MarketerX Regular Member

    Joined:
    Mar 7, 2010
    Messages:
    398
    Likes Received:
    120
    Yeah clickjacking isn't illegal.

    Call it by its "Legit" name.. UI Redressing..

    And yes I have access to the iframed pages source and can get the FORM's ID.

    I will give this a try and let ya know how it works...thanks guys..
     
  7. cyklotrial

    cyklotrial Regular Member

    Joined:
    Oct 13, 2008
    Messages:
    248
    Likes Received:
    82
    Location:
    Wonderland
    ok ok its not illegal in 100%. But most action maked by clickjacking are fraudently (illegal).
     
  8. mward

    mward Newbie

    Joined:
    Oct 19, 2010
    Messages:
    43
    Likes Received:
    3
    Occupation:
    manager
    Location:
    uk
    the other way to do it is have a onkeypress event handler in javascript and detect the keycode for enter.