473,407 Members | 2,315 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 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 7755
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.