freephoneid Posted September 16, 2008 Share Posted September 16, 2008 Hi, I'm using PHP 5. I've 2 forms in 1 php page & multiple buttons (Edit & Delete) as well. When I click the Edit or Delete button using mouse, it behavous as expected. However, when I hit the enter key, it does submit the form but the POST data does not contain any of these buttons (delete or edit) info. What I need is I should be able to get the Edit button in POST but I'm not getting EDIT button at all. Eg: <form action=...method="post"> <input type="submit" name="selectcompany" value="Edit " onclick="return validateEdit();"> <input type="submit" name="deletecompany" value="Delete" onclick="return validateDelete();"> </form> When the form is submitted, i'm expecting the $_POST['selectcompany'] but strangely, on hitting enter key, POST data does not contain the button at all. Can any one help me? Thanks! Link to comment https://forums.phpfreaks.com/topic/124558-post-data-lost-on-enter-key-but-works-on-mouse-click/ Share on other sites More sharing options...
DarkWater Posted September 16, 2008 Share Posted September 16, 2008 Internet Explorer does not set the submit buttons in the POST array if you use the Return key. Therefore, you could do something like: <?php if ($_SERVER['REQUEST_METHOD'] == "POST") { } ?> Link to comment https://forums.phpfreaks.com/topic/124558-post-data-lost-on-enter-key-but-works-on-mouse-click/#findComment-643362 Share on other sites More sharing options...
freephoneid Posted September 16, 2008 Author Share Posted September 16, 2008 Hi, Thanks for your kind reply. however how can it sends data on mouse click & not with enter key? The same page works fine with Firefox with enter & mouse key BOTH!! Do you have any other solution? Thanks again! Link to comment https://forums.phpfreaks.com/topic/124558-post-data-lost-on-enter-key-but-works-on-mouse-click/#findComment-643365 Share on other sites More sharing options...
DarkWater Posted September 16, 2008 Share Posted September 16, 2008 That's just how IE is programmed. Instead of using like: if (isset($_POST['submit'])) { } Instead of that, use the code that I said. Link to comment https://forums.phpfreaks.com/topic/124558-post-data-lost-on-enter-key-but-works-on-mouse-click/#findComment-643366 Share on other sites More sharing options...
freephoneid Posted September 16, 2008 Author Share Posted September 16, 2008 Hi, Thanks again for the reply.... Well, the reason I asked for alternate solution is because I've multiple forms with multiple buttons. The solution which you've given is just the check for POST method.....which might satisfy other forms conditions as well....thts why I'm little afraid of using that solution.... Any other cool suggestion or soln? Thanks! Link to comment https://forums.phpfreaks.com/topic/124558-post-data-lost-on-enter-key-but-works-on-mouse-click/#findComment-643369 Share on other sites More sharing options...
DarkWater Posted September 16, 2008 Share Posted September 16, 2008 http://www.thefutureoftheweb.com/blog/submit-a-form-in-ie-with-enter Link to comment https://forums.phpfreaks.com/topic/124558-post-data-lost-on-enter-key-but-works-on-mouse-click/#findComment-643372 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.