Results 1 to 8 of 8

Thread: Pressing "Enter" to submit form

  1. #1

    Thread Starter
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Pressing "Enter" to submit form

    I've got a search form that users enter a stock code then click search and the results are displayed. My problem is a lot of users enter the stock code then hit "Enter" but with my checking (below) is doesn't think the search button has been clicked.

    How can I capture "Enter" being pressed so I can perform the required search?

    PHP Code:

    //Check if form has been submitted
    if (!isset($_POST['submit']) ) {
    //display search form
    }

    else {
    //Show search results


  2. #2
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Pressing "Enter" to submit form

    You don't "capture" the enter in a web application. Clicking on the button or pressing enter will yield the same result.

    It depends on how your HTML is setup. If it's in the same form, pressing enter should submit the form (unless it's a textarea).

    Also, I've never been a fan of isset. I like checking for nulls
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  3. #3

    Thread Starter
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Pressing "Enter" to submit form

    Thanks kasracer. I have a textbox as the only item in the form (along with submit button) If I type a stock code then hit enter the page re-loads but shows the search page again instead of search results.

    This is my code.

    PHP Code:
    <form method="post" action="<?php echo $PHP_SELF;?>">
    <table width="25%" border="0" cellpadding="2" cellspacing="1" bgcolor="cccccc"><tr>
    <td width="50%"><b>Stock Code:</b></td>
    <td width="50%"><input name="code" type="text" maxlength="5" size="5"></td>
    </tr>
    <tr>
    </table><br>
    <input type="submit" name="submit" value="Search" style="font-size: 8pt; font-weight: bold">
    </form>

  4. #4
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Pressing "Enter" to submit form

    No idea why enter just doesn't work then. I take it you don't have some sort of page accessable to us, do you? Does it work correctly in any web browsers?
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  5. #5

    Thread Starter
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Pressing "Enter" to submit form

    Attached is a page with all the code.

    It works in Mozilla but not IE
    Attached Files Attached Files

  6. #6
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Pressing "Enter" to submit form

    It might be because the Submit button is outside of the table and the text field is inside the table.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  7. #7

    Thread Starter
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Pressing "Enter" to submit form

    No such luck

    Does it work for you in IE?

  8. #8

    Thread Starter
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Pressing "Enter" to submit form

    anyone

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