SharkBait Posted September 27, 2006 Share Posted September 27, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/22296-forms-submit-button-doesnt-accept-enter-key/ Share on other sites More sharing options...
SharkBait Posted September 27, 2006 Author Share Posted September 27, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/22296-forms-submit-button-doesnt-accept-enter-key/#findComment-99896 Share on other sites More sharing options...
fenway Posted September 27, 2006 Share Posted September 27, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/22296-forms-submit-button-doesnt-accept-enter-key/#findComment-99919 Share on other sites More sharing options...
SharkBait Posted October 2, 2006 Author Share Posted October 2, 2006 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* Quote Link to comment https://forums.phpfreaks.com/topic/22296-forms-submit-button-doesnt-accept-enter-key/#findComment-102398 Share on other sites More sharing options...
Daniel0 Posted October 2, 2006 Share Posted October 2, 2006 Do [code]if(count($_POST)>0)[/code] instead. Quote Link to comment https://forums.phpfreaks.com/topic/22296-forms-submit-button-doesnt-accept-enter-key/#findComment-102408 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.