[thelist] Can't submit form data with 'enter' key in IE

Jim Davis jim4realty at gmail.com
Wed Mar 8 12:46:19 CST 2006


Still having problems with use of 'enter' in IE not returning the search.

I took the advice of Volkan and others and changed the input line for the
button to read:

<input name="btnSearch" type="submit" value="Search" />

The first few lines of the php now reads:

if (isset($_GET['btnSearch'])) {
$nameGuess = "%".$_GET['agent_name']."%";

Max identified the source of the problem with IE. Here is the url returned
by FF when the 'enter' key is used with nothing in the text box of the form:

http://www.previewp.com/roster/roster_searchall.php?agent_name=&btnSearch=Search

While IE returns this:

http://www.previewp.com/roster/roster_searchall.php?agent_name=

As Max said, when the keyboard 'enter' key is used rather than clicking the
'Search' button, IE ignores the value found in <input name="btnSearch"
type="submit" value="Search" />.

I tried various iterations of the code Max suggested, but could not make it
work.

How can I force IE to include the value of the 'Search' button? Here is the
current link to use to see the problem:

http://www.previewp.com/roster/roster_searchall.php?agent_name=&btnSearch=Search

As a side note, here is the code I am using to get paged results:

$totalrows = mysql_num_rows($resultCount);
    $totalpages = ceil($totalrows / $pagesize);
    $currentpage = ($recordstart / $pagesize) + 1;
        echo "<div class=\"pager\">";
        // Create the 'Previous' link
        if ($recordstart > 0) {
        $prev = $recordstart - $pagesize;
        $url = $_SERVER['PHP_SELF']."?recordstart=$prev&btnSearch=Search";
        echo "<div class=\"prev\"><a href=\"$url\">Previous Page</a></div>";
        }

        // Create the 'Next' link
        if ($totalrows > ($recordstart + $pagesize)) {
        $next = $recordstart + $pagesize;
        $url = $_SERVER['PHP_SELF']."?recordstart=$next&btnSearch=Search";
        echo "<div class=\"next\"><a href=\"$url\">Next Page</a></div>";
        }
        }
    echo "<div class=\"pagenums\">Page $currentpage of $totalpages</div>";
    echo "</div>";
    //Close the connection...

Thanks to all of you that have taken your valuable time to offer help.

Jim


On 3/7/06, Max Schwanekamp <lists at neptunewebworks.com> wrote:
>
> Jim Davis wrote:
> > I am using <input name="submit" type="submit" value="Submit">.
> >
> http://www.previewp.com/roster/roster_searchall.php?agent_name=&submit=Submit
>
> Your php script is apparently looking for $_GET['submit'].  Submitting
> the form without clicking Submit in IE sends the text field, but not the
> submit value, whereas FF and others will include the submit value by
> default (IE's behavior seems more correct to me in this case).  Try
> something like:
> <?php
> if (!empty($_GET) && $_GET['agent_name']) {
>         //do the search
> } else {
>         //show error msg, ignore request, etc.
> }
> ?>
>
> HTH
> --
> Max Schwanekamp
> http://www.neptunewebworks.com/
>
>



More information about the thelist mailing list