468,247 Members | 1,296 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,247 developers. It's quick & easy.

form with multiple submits

Hello,

I have a self - submitting form with multiple submits and I want to
detect after the submit which button is pressed.

Code example:
<form name="example" method="post" action="/test.php">
<input type =submit name="add"> form elements but also

<a href="#" onClick=document.myForm.submit()>edit</a>
<a href="#" onClick=document.myForm.submit()>modify</a>

</form>

If I submit the form by clicking either of these elements, how do I
detect in PHP which element was used to submit the form?

TIA,

Marc
Jul 17 '05 #1
5 7556
Marc wrote:
Hello,

I have a self - submitting form with multiple submits and I want to
detect after the submit which button is pressed.

Code example:
<form name="example" method="post" action="/test.php">
<input type =submit name="add"> form elements but also

<a href="#" onClick=document.myForm.submit()>edit</a>
<a href="#" onClick=document.myForm.submit()>modify</a>

</form>

If I submit the form by clicking either of these elements, how do I
detect in PHP which element was used to submit the form?
You don't.

Try this:

<html>
<body>
<?
// received?
if (isset($_POST["myAction"])) {
echo $_POST["myAction"]." clicked!";
}
?>
<br>
<form name="example" method="post" action="test.php">
<input type=submit name="myAction" value="ADD">
<input type=submit name="myAction" value="EDIT">
<input type=submit name="myAction" value="MODIFY">
</form>

</body>
</html>


TIA,
You're welcome

Marc


Regards,
Erwin Moller
Jul 17 '05 #2
why have you named the submit button "add"? sounds more like an
action.
how bout naming it a nice generic "submit"

<form name="myForm" method="post">
<INPUT type="hidden" name="action" value="edit">default action = edit
<input type="submit" name="submit">

<a href="#" onClick="document.myForm.action.value='edit';
document.myForm.submit();">edit</a>
<a href="#" onClick="document.myForm.action.value='modify';
document.myForm.submit();">modify</a>
me**********@yahoo.com (Marc) wrote in message news:<ac**************************@posting.google. com>...
Hello,

I have a self - submitting form with multiple submits and I want to
detect after the submit which button is pressed.

Code example:
<form name="example" method="post" action="/test.php">
<input type =submit name="add"> form elements but also

<a href="#" onClick=document.myForm.submit()>edit</a>
<a href="#" onClick=document.myForm.submit()>modify</a>

</form>

If I submit the form by clicking either of these elements, how do I
detect in PHP which element was used to submit the form?

TIA,

Marc

Jul 17 '05 #3
bk***********@yahoo.com (Brad Kent) wrote in message news:<7a**************************@posting.google. com>...
why have you named the submit button "add"? sounds more like an
action.
how bout naming it a nice generic "submit"

<form name="myForm" method="post">
<INPUT type="hidden" name="action" value="edit">default action = edit
<input type="submit" name="submit">

<a href="#" onClick="document.myForm.action.value='edit';
document.myForm.submit();">edit</a>
<a href="#" onClick="document.myForm.action.value='modify';
document.myForm.submit();">modify</a>
me**********@yahoo.com (Marc) wrote in message news:<ac**************************@posting.google. com>...
Hello,

I have a self - submitting form with multiple submits and I want to
detect after the submit which button is pressed.

Code example:
<form name="example" method="post" action="/test.php">
<input type =submit name="add"> form elements but also

<a href="#" onClick=document.myForm.submit()>edit</a>
<a href="#" onClick=document.myForm.submit()>modify</a>

</form>

If I submit the form by clicking either of these elements, how do I
detect in PHP which element was used to submit the form?

TIA,

Marc


Thanks Brad, this is what I was looking for!

Marc
Jul 17 '05 #4
me**********@yahoo.com (Marc) wrote in message news:<ac**************************@posting.google. com>...
bk***********@yahoo.com (Brad Kent) wrote in message news:<7a**************************@posting.google. com>...
why have you named the submit button "add"? sounds more like an
action.
how bout naming it a nice generic "submit"

<form name="myForm" method="post">
<INPUT type="hidden" name="action" value="edit">default action = edit
<input type="submit" name="submit">

<a href="#" onClick="document.myForm.action.value='edit';
document.myForm.submit();">edit</a>
<a href="#" onClick="document.myForm.action.value='modify';
document.myForm.submit();">modify</a>
me**********@yahoo.com (Marc) wrote in message news:<ac**************************@posting.google. com>...
Hello,

I have a self - submitting form with multiple submits and I want to
detect after the submit which button is pressed.

Code example:
<form name="example" method="post" action="/test.php">
<input type =submit name="add"> form elements but also

<a href="#" onClick=document.myForm.submit()>edit</a>
<a href="#" onClick=document.myForm.submit()>modify</a>

</form>

If I submit the form by clicking either of these elements, how do I
detect in PHP which element was used to submit the form?

TIA,

Marc


Hmmm.. Now I get

document.myForm.submit() is not a function in the JavaScript console of Netscape...

Used to work....
????

Marc
Jul 17 '05 #5
sorry.. I'm real slow to get back to this thread...
netscape doesn't like the submit button being named "submit"
it gets confused with "document.myForm.submit();"

better late than never?

me**********@yahoo.com (Marc) wrote in message news:<ac**************************@posting.google. com>...
me**********@yahoo.com (Marc) wrote in message news:<ac**************************@posting.google. com>...
bk***********@yahoo.com (Brad Kent) wrote in message news:<7a**************************@posting.google. com>...
why have you named the submit button "add"? sounds more like an
action.
how bout naming it a nice generic "submit"

<form name="myForm" method="post">
<INPUT type="hidden" name="action" value="edit">default action = edit
<input type="submit" name="submit">

<a href="#" onClick="document.myForm.action.value='edit';
document.myForm.submit();">edit</a>
<a href="#" onClick="document.myForm.action.value='modify';
document.myForm.submit();">modify</a>
me**********@yahoo.com (Marc) wrote in message news:<ac**************************@posting.google. com>...
> Hello,
>
> I have a self - submitting form with multiple submits and I want to
> detect after the submit which button is pressed.
>
> Code example:
> <form name="example" method="post" action="/test.php">
> <input type =submit name="add"> form elements but also
>
> <a href="#" onClick=document.myForm.submit()>edit</a>
> <a href="#" onClick=document.myForm.submit()>modify</a>
>
> </form>
>
> If I submit the form by clicking either of these elements, how do I
> detect in PHP which element was used to submit the form?
>
> TIA,
>
> Marc


Hmmm.. Now I get

document.myForm.submit() is not a function in the JavaScript console of Netscape...

Used to work....
????

Marc

Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Aaron C | last post: by
16 posts views Thread by Philippe C. Martin | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.