472,982 Members | 2,580 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,982 software developers and data experts.

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 7733
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Randell D. | last post by:
Folks, I am working on a contact db using PHP and MySQL. My results so far outputs a slimed down version of records to the browser. I would like to implement a method whereby the user can...
12
by: Forti2ude | last post by:
Hello, I have a simple form... <form> <select name="foo" multiple> <option value="1">one</option> <option value="2">two</option> <option value="3">three</option> </select>
1
by: Aaron C | last post by:
I'm validating a form that has two buttons ("Next" and "Back"). The call to the script is currently in the form's onSubmit() handler. Upon pressing either button, the script runs. This is...
5
by: Red | last post by:
Hi, I'm not very familiar with Javascript. I usually leave that kind of stuff up to Dreamweaver, but i'm starting to need a little more than it can offer. I have an asp page which creates a...
16
by: Philippe C. Martin | last post by:
Hi, I am trying to change the data in a form field from python. The following code does not crash but has no effect as if "form" is just a copy of the original html form. Must I recreate the...
6
by: RobR | last post by:
We have a customer using our application that has a problem. Within our app, we have a two different forms (one generates an email, the other a fax via a webservice). When they click the submit...
14
Plater
by: Plater | last post by:
I'm going to stab myself in the face. I have a page with a single form. Regular old html. There are a few checkboxes and textboxes and and two submit buttons (I hope that's not the issue...) The...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.