Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Dec 2002
    Location
    New York State
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Press enter key to click a specific submit button

    Hey:

    I have several "submit" buttons on a form. I want users to be able to hit the "enter" key to submit the form. The page used to "post" the information checks for specifically what form button was pushed to submit the form before executing the appropriate code. I am automatically submitting the page when the enter key is hit, but it is defaulting to the first option of executed code in the post page.

    Example - I have an "update" button and a "delete" button on the form. On the post page, I first check to see if the delete button was hit. When I press enter on the form, it simply answers yes to the first question (did they click the delete button), and the code is executed. I really wanted to emulate that the update button was hit.

    So -- is there a way to hit the enter button, and in the js code, mandate that it was the "update" button that was clicked?

    Thanks.

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try this.


    .....Willy

  • #3
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    afraid of my answer at the ranch?

  • #4
    New Coder
    Join Date
    Jan 2009
    Location
    Bristol, England
    Posts
    43
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Help needed: upon pressing the [enter] key, the submit button isn't selected

    PLEASE HELP ME!!! Lol, I'm dying here...
    I have a similar problem, ok; here goes...

    This is a problem that has been pestering me for a long time now.
    I have written a simple code in HTML which uses frames; basically, when you type in something in the text-box, if it

    recognizes it from the script it will take you to it's set page, and if it's doesn't, then it'll take you to another set page

    informing the user that it doesn't recognize your entry.
    It's like a ChatBot basically.

    What I need help with though is two things:
    1. my first issue is when you up on pressing the [Enter], or [Return] key it does nothing, and you instead have to click the

    'Submit' button; what I want is to be able to press the [Enter] key within the text-box and it automatically clicking that

    button for me (like a search engine or login page would, etc)

    2. And my second problem is that, when I load up my page; I want my cursor to automatically be set in the text-box, like with

    Google; so that as soon as you load up the page you can type something in, and it'll appear in the text-box automatically,

    without you having to click the textbox first.

    If you geniuses are able to solve this for me, I literally will love you forever. Haa ha
    I'm not kidding, I have been trying to figure this out for ages, so I wish you the best in cracking a method.
    Anyway, I would love to hear from you soon... All the best And a million thanks for reading/helping.

    ---

    There are two frames, and one index to link them both together.
    This is the 'header' frame, and all documents from this frame, shall be displayed in the 'main' frame.

    Here's a copy of my code:

    <html>
    <HEAD>

    <meta http-equiv="Content-Language" content="en-gb">

    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    function Login(){
    var done=0;
    var data=document.login.data.value;
    if (data=="8") { parent.main.window.location="8.html"; done=1; }
    if (done==0) { alert("Could you please rephrase that?"); }
    }
    // End -->
    </SCRIPT>

    <title>Header</title>
    <base target="_self">

    <BODY>

    <center>
    <form name=login>
    <table width=225 border=0 cellpadding=3 style="border-collapse: collapse" bordercolor="#111111" cellspacing="0">
    <tr><td>
    <p align="center"><input type=text name=data size="20"></td><td>
    <p align="center"><input type=button value="Submit" onClick="Login()"></td></tr>
    </table>
    </form>
    </center>


    </html>

  • #5
    Senior Coder
    Join Date
    Oct 2008
    Location
    Long Beach
    Posts
    1,196
    Thanks
    36
    Thanked 164 Times in 164 Posts
    Please don't double post. I answered both your questions in your OP.
    Feel free to e-mail me if I forget to respond ;)
    ohsosexybrit@gmail.com

  • #6
    New to the CF scene
    Join Date
    Jun 2010
    Location
    Chennai
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    @jameswsparker:
    Hi James, if you haven't got any replies yet, then, I have got a solution for the first point u were asking for in the below line of your code;

    Originally posted:
    <p align="center"><input type=button value="Submit" onClick="Login()"></td></tr>

    Modified one:
    <p align="center"><input type=submit value="Submit" onClick="Login()"></td></tr>

    Cheers!!!!!!!!!
    Last edited by vijaydharma; 06-09-2010 at 09:58 AM. Reason: Updates are not correctly mentioned


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •