RE: [PHP] Form with 2 submit buttons

From: Date: Wed, 06 Sep 2000 01:57:00 +0000
Subject: RE: [PHP] Form with 2 submit buttons
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-15416@lists.php.net to get a copy of this message
Hi, I was doing something like this, but then I wanted to do some server side error validation. I think I'll end up doing it this way, as I can't see any other way to get around it. Why is it that when I have a submit button declared as: <INPUT type=submit name="btnSubmit" value="Submit Query"> When I hit the "Enter" key, $btnSubmit = "" and if I press the button with the mouse, $btnSubmit = "Submit Query". How do you get around that? Thanks, Sam > -----Original Message----- > From: root@wren.cfs.net.au [mailto:root@wren.cfs.net.au]On Behalf Of > Eric > Sent: Wednesday, 6 September 2000 11:47 > Cc: PHP General > Subject: Re: [PHP] Form with 2 submit buttons > > > > you can use two separate sets of form tags or you can do this > with javascript. > i've got a page with 4 submit buttons and use the following > javascript to get > me what i want. > > function goto1() { > document.forms[0].action="request.phtml?pid=<% echo $pid %>"; > document.master.submit(); > } > function goto2() { > document.forms[0].action="request2.phtml?pid=<% echo $pid %>"; > document.master.submit(); > } > function goto3() { > document.forms[0].action="edit.phtml?pid=<% echo $pid %>"; > document.master.submit(); > } > function goto4() { > document.forms[0].action="del.phtml?pid=<% echo $pid %>"; > document.master.submit(); > > <form method=get> > <font face="Verdana, Arial, sans-serif"> <font > size="-1"> > <input type="submit" name="Submit2" > value="Request"onClick="goto1()"> > <input type="submit" name="Submit2" > value="Request2"onClick="goto2()"> > <input type="submit" name="Submit2" > value="Edit"onClick="goto3()"> > > <input type="submit" name="Submit2" > value="Delete"onClick="goto4()"> > </form> > > > HTH - Eric > > > Samantha Savvakis wrote: > > > HI, > > > > I want to know what is the best way to go about this situation. > > I have a set of pages that make up a wizard type implementaion, > so I have a > > "Previous" and a "Next" button on each page. > > > > Both of these buttons are on the Same <FORM>. Each button has a > different > > action -eg. Previous button goes to page1.php and Next button goes to > > page3.php. > > > > When I submit, it submits to itself. Here is code example: > > > > if (btnNext is pressed) > > { > > $bok = checkmandatories(); > > if ($bok) > > goto "next" page - page3.php; > > } > > else if (btnPrev is pressed) > > { > > goto "previous" page - page1.php; > > } > > > > <BODY> > > <FORM name=details METHOD=POST> > > <INPUT type=text name....> > > <INPUT type=text name....> > > > > <INPUT type=submit name=btnPrev value="Previous"> > > <INPUT type=submit name=btnNext value="Next"> > > </FORM> > > </BODY> > > > > How do I determine which button I have pressed? There don't seem to be > > values for $btnPrev and $btnNext. > > > > Also, second problem, how then do I pass all the form > name/value pairs to > > the "action". Is there a way "without" having to build up the > > name/value > > pair string to the page if I do a submitting form like this? > > > > I'm sure there is a better way to doing this. > > > > Thanks! > > Sam > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > For additional commands, e-mail: php-general-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#15416) next »