SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Addict Messiah's Avatar
    Join Date
    Jun 2001
    Location
    Bloomington, In.
    Posts
    216
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Using keyboard to submit form issue.

    Ok, my turn to ask a question.

    I have a form that submits correctly when using your mouse to click on the submit button in the form, however, it breaks when using the enter key on your keyboard. Anyone ever run into this issue before? It happens on every form, not just one in particular which I find odd.

    Any thoughts would be appreciated.
    Messiah | Ink-Press: web publishing simplified!

  2. #2
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Location
    Lancaster, Ca. USA
    Posts
    12,305
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Not sure how this would be a PHP issue... Do you have any onSubmit actions assigned to the submit button? Might try moving them to the form tag itself.
    Wayne Luke
    ------------


  3. #3
    SitePoint Addict Messiah's Avatar
    Join Date
    Jun 2001
    Location
    Bloomington, In.
    Posts
    216
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wayne,

    To be honest, I am not exactly sure how this is a php question either. Although, in my defense, I am using php to post the vars. My forms are basic, in that there is nothing extraneous in the markup, no js etc... I slapped a test case together to prove a point:

    PHP Code:
    <?php

    if ( isset( $_POST['text'] ) && $_POST['text'] != "" )
    {
        echo 
    "You posted the following value: " $_POST['text'];
    }

    else
    {

    ?>
    Testing post. Input text and use your enter key to submit.
    <form action="test.php" method="post">
      <input name="text" type="text" />
      <input type="submit" />
    </form>
    <?php

    }

    ?>

    As you can see, this is as simple as it can get. Yet using the keyboards enter key to submit the form fails.
    Messiah | Ink-Press: web publishing simplified!

  4. #4
    SitePoint Enthusiast powdermonster's Avatar
    Join Date
    Apr 2002
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could use javascrpt to stop the enter button from submitting the forum

    http://www.sitepointforums.com/showthread.php?t=144539
    Keri

    jamesbond-007.info
    cPanel Guide

  5. #5
    SitePoint Wizard
    Join Date
    Oct 2001
    Location
    Tucson, Arizona
    Posts
    1,858
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Messiah: What browser are you using?

  6. #6
    SitePoint Addict Messiah's Avatar
    Join Date
    Jun 2001
    Location
    Bloomington, In.
    Posts
    216
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could use javascrpt to stop the enter button from submitting the forum
    Fixing the problem would be the proper solution, rather than masking it with a pseudo fix that only works some of the time.

    What browser are you using?
    A whole host of browsers including but not limited to: Internet Explorer 5.0 / Internet Explorer 6.0 / Firebird 0.7 / Opera 7.1 / Openwave 6.2.2 (simulator) / Web TV 2.6 (simulator) all on Windows 2000 Server. However, the problem seems to have remedied itself after a reboot. Unless the problem returns, chalk it up to fluke I suppose.
    Messiah | Ink-Press: web publishing simplified!

  7. #7
    SitePoint Wizard
    Join Date
    Oct 2001
    Location
    Tucson, Arizona
    Posts
    1,858
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you have any kind of keyboard shortcut mapper running in the background? Are you using any apps that have global shortcuts (Winamp, for example)?

  8. #8
    SitePoint Addict Messiah's Avatar
    Join Date
    Jun 2001
    Location
    Bloomington, In.
    Posts
    216
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nope, no keyboad mappers and no apps with global shortcuts that I am aware of.
    Messiah | Ink-Press: web publishing simplified!

  9. #9
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Location
    Lancaster, Ca. USA
    Posts
    12,305
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Your test script works fine for me under Windows XP running PHP 4.3.3 under Apache 1.3.27 as a module in both Mozilla Firebird 0.7 and Internet Explorer 6.0 XPSP2.

    Both processed properly using either the Enter Key or the Submit Button to process the form.
    Wayne Luke
    ------------


  10. #10
    SitePoint Member
    Join Date
    Jan 2003
    Location
    Fairbanks, Alaska
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Messiah,

    I'm experienceing the same thing on a site I just developed. The form in question is a search feature that I am including into my site pages with php. Users can submit a search using the enter key when they are browsing in Netscape, but not in Explorer 6.x.

    Needless to say, my users are not amused that this is happening, so as I troubleshoot this I'll be sure to post back to this topic.

    Sorry I have no immediate help for ya

    Cheers,
    Christen

  11. #11
    SitePoint Member
    Join Date
    Jan 2003
    Location
    Fairbanks, Alaska
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, I looked around the board a bit and found more people having the same problem. I found a fix for my script in this post :
    http://www.sitepointforums.com/showthread.php?t=135206

    Aska had the solution and this is an excerpt:

    I'm guessing here but a similar thing happened to me some time ago... TheMissingElf, in your form processing code, are you using the POST['search'] variable to check if the form has been submitted? If so, by pressing "Enter" in IE, the 'search' button does not pass its value to the target page.

    You can modify your form like so and it will work in IE also.

    The key is the hidden input field, which gets submitted regardless of whether the "enter" key was used or not:


    Code:
    <form action="<?=$_SERVER['PHP_SELF']?>" method="post">
    Code:
    Text Search 
    <input type="text" name="searchtext" value="">
    <input type="hidden" name="search" value="go">
    <input type="submit" name="searchBTN" value="GO">
    </form>



    Hope this helps,
    Christen


Bookmarks

Posting Permissions

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