This is a discussion on Two Actions in a Form? within the PHP General forums, part of the PHP Programming Forums category; Hi there, I realize this is a group for PHP, but this question is related. What I want to do ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi there,
I realize this is a group for PHP, but this question is related. What I want to do is have one action in a form execute if the user clicks on one button, and another action execute if the user clicks on another button. The actions will point to PHP programs. Can someone fill me in on what the HTML is for this. I can't remember. Thanks a bunch in advance, Dimitri Marshall |
|
|||
|
Dimitri Marshall wrote:
> Hi there, > I realize this is a group for PHP, but this question is related. > > What I want to do is have one action in a form execute if the user clicks on > one button, and another action execute if the user clicks on another button. > The actions will point to PHP programs. > > Can someone fill me in on what the HTML is for this. I can't remember. > > Thanks a bunch in advance, > Dimitri Marshall > This is a JavaScript item. Being that this is a php list, and I haven't messed with JavaScript in quite some time, my syntax may be a bit off, but it should get you going.... Setup the form the way you normally would, with the action of the form set to the first page you want it to submit too. For the second page, you'll need to set up a JS function, something like... function submitForm(){ document.forms[0].action = 'url/of/second/page.php'; document.forms[0].submit; } And your second button would be like this.... <form onSubmit="submitForm()"> <input type="submit" value="Second Button" /> </form> The second button needs to be placed outside of your first form. Like I said, my syntax is probably a bit off, but this is the general idea. -- By-Tor.com It's all about the Rush http://www.by-tor.com |
|
|||
|
--- Dimitri Marshall <webmaster@dyntdesign.com> wrote:
> What I want to do is have one action in a form execute if the user > clicks on one button, and another action execute if the user clicks > on another button. The actions will point to PHP programs. > > Can someone fill me in on what the HTML is for this. There is no HTML for this, since a form's action attribute can only have a single value. All you need to do, however, is have the PHP script that receives the post to distinguish between which button the user clicked. Name your submit button different names, then use print_r($_POST) or print_r($_GET) - depending on whether you use POST or GET, and I think you'll see what you need to be checking. Hope that helps. Chris ===== Chris Shiflett - http://shiflett.org/ PHP Security Handbook Coming mid-2004 HTTP Developer's Handbook http://httphandbook.org/ RAMP Training Courses http://www.nyphp.org/ramp |