Submit button and enter key

Discussion in 'Web Development & Web Hosting' started by twizzle, Dec 23, 2010.

  1. twizzle

    twizzle Gigabyte Poster

    1,842
    43
    104
    On my form i have a submit button that then runs a JS to do a whois lookup. I also need this button to work when the enter key is clicked

    my code is print "<input type=\"button\" value=\"Find\" onClick=\"javascript:whois();\">"; for the button but i have no idea on how to focus the enter key.

    Any help?
     
    Certifications: Comptia A+, N+, MS 70-271, 70-272
    WIP: Being a BILB,
  2. soundian

    soundian Gigabyte Poster

    1,460
    71
    107
    Is there not an button.Focus() method?
     
    Certifications: A+, N+,MCDST,MCTS(680), MCP(270, 271, 272), ITILv3F, CCENT
    WIP: Knuckling down at my new job
  3. twizzle

    twizzle Gigabyte Poster

    1,842
    43
    104
    I wouldnt know, this is all done in PHP and JS by someone else, i'm having to pick up from them and i know nothing on this. Where would that code go? I assum in teh form on same part as the submit button, or would it go in the JS?
     
    Certifications: Comptia A+, N+, MS 70-271, 70-272
    WIP: Being a BILB,
  4. soundian

    soundian Gigabyte Poster

    1,460
    71
    107
    In the JS you could use document.yourForm.yourButton.focus();
    That would automatically focus on the button and would allow you the same functionality of the onclick event until someone changes focus on the page.

    I'm not sure if that will do what you want. It really depends on what's on the rest of the page.
     
    Certifications: A+, N+,MCDST,MCTS(680), MCP(270, 271, 272), ITILv3F, CCENT
    WIP: Knuckling down at my new job

Share This Page

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.