Bluehost.com Web Hosting $6.95

Two Actions in a Form?

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-26-2003
Dimitri Marshall
 
Posts: n/a
Default Two Actions in a Form?

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
Reply With Quote
  #2 (permalink)  
Old 11-26-2003
John Nichel
 
Posts: n/a
Default Re: [PHP] Two Actions in a Form?

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
Reply With Quote
  #3 (permalink)  
Old 11-26-2003
Chris Shiflett
 
Posts: n/a
Default Re: [PHP] Two Actions in a Form?

--- 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
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 04:50 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0