Jump to content

Archived

This topic is now archived and is closed to further replies.

SharkBait

Form's Submit Button doesn't accept 'Enter Key'

Recommended Posts

In IE my form works but when you try and hit enter, it submits the information as if nothing was sent.

In Firefox when you hit the enter key after filling out the form it works fine.

What is it that IE does and Firefox doesnt?  Or is it the other way around?

This is the code:
[code]
<div class="navcontainer">
Search
<div class="navsub">
<table style="font-size: 65%; margin:0;" border="0" cellpadding="2" cellspacing="0">
<form action="search.php" method="post">
<tr>
<td colspan="2" align="center">
<select name="table">
<option value="All">All Models</option>
<?php
asort($UNITS);
foreach($UNITS as $unit) {
$table = key($UNITS);
echo "<option value=\"{$table}\"";
if (isset($_SESSION['searchMOD'])) {
if (($_SESSION['searchMOD'] == $table) || (isset($_POST['table']) && $_POST['table'] == $table)){
echo " selected=\"selected\" ";
}
}
echo ">{$unit}</option>\n";
next($UNITS);
}
?>
</select><br />
</td>
</tr><tr>
<td colspan="2">
<p>
<select name="type">
<option value="mac">MAC</option>
<option value="sn">SN</option>
<option value="rma">RMA</option
</select>
</p>
</td>
</tr><tr>
<td colspan="2" align="center">
<input type="text" name="search" size="15" maxlength="20" accesskey="/" title="Alt /"
value="<?php if(isset($_POST['search'])) echo $_POST['search']; ?>" />
</td>
</tr><tr style="padding:0; margin:0;">
<td colspan="2" align="center">
<input type="submit" name="submit" value="Search" accesskey="." title="alt ."/>
</td>
</tr>
</form>
</table>
</div>
</div>
[/code]

I am unsure why in IE you can not just hit the 'enter' key to submit the form.....or why it doesnt handle it properly

Share this post


Link to post
Share on other sites
Ah I figured it out.

IE is dumb.. dumb dumb dumb.  ;)

When you use the enter key to submit a form, IE does not set the variable for the <input type="submit"> because it was not clicked.  Firefox and the rest are able to figure out when you hit the enter key, that you're submitting the form.

So in my script I checked [code=php:0]if (isset($_POST['submit']) || isset($_POST['textboxinput']))[/code] and it seems to work fine. Though the Enter key on the numpad is different than the enter (return) key on the rest of the keyboard.. but thats another job to figure out

Share this post


Link to post
Share on other sites
If you didn't click the button, it shouldn't be set... if FF does do so, it's a mistake. Besides, why not just check to see if any data was POSTed?

Share this post


Link to post
Share on other sites
I just check to see if the form is is submited via $_POST and then I got into checking the form's elements to see if they have been posted.  *shrug*

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.