Re: 2 submit buttons.

From: Date: Mon, 14 Feb 2011 21:18:14 +0000
Subject: Re: 2 submit buttons.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-311284@lists.php.net to get a copy of this message
On Mon, Feb 14, 2011 at 03:35:02PM -0400, Paul Halliday wrote: > I have 2 buttons on a page: > > if (isset($_POST['botton1'])) {dothing1();} > if (isset($_POST['button2'])) {dothing2();} > > They both work as intended when I click on them. If however I click > within a text box and hit enter, they both fire. > > Is there a way to stop this? Check your code. My experience has been that forms with multiple submits will fire the *first* submit in the form when you hit Enter in a text field or whatever. I just tested this and found it to be true. Now, I'm doing this in Firefox on Linux. I suppose there could be differences among browsers, but I suspect that the specs for HTML mandate the behavior I describe. Paul -- Paul M. Foster http://noferblatz.com

« previous php.general (#311284) next »