473,746 Members | 2,283 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

2 submit button calling one page

I need to have 2 submit buttons in one form calling the same page. I just
need to know which was used. Being able to pass a hidden form input for
each would be ideal. How can I do this??

Thanks!,Adrian
Jul 20 '05 #1
6 5680
Adrian wrote:
I need to have 2 submit buttons in one form calling the same page. I just
need to know which was used.


<input type="submit" name="s" value="1">
<input type="submit" name="s" value="1">

<?php

print $_REQUEST['s'];

?>

No need for JavaScript.
--
David Dorward <http://dorward.me.uk/>
Jul 20 '05 #2
On Tue, 20 Jan 2004 22:56:04 +0000, David Dorward <do*****@yahoo. com>
wrote:
Adrian wrote:
I need to have 2 submit buttons in one form calling the same page. I
just
need to know which was used.


<input type="submit" name="s" value="1">
<input type="submit" name="s" value="1">

<?php

print $_REQUEST['s'];

?>

No need for JavaScript.


I assume that the values for the two buttons were supposed to be different?

To the OP: If the submit button[1] has a name and value, that pair will be
sent with the rest of the data on submission. If there is more than one
button, only the clicked button will have its name/value pair sent. This
will allow you to check which button was pressed server-side.

If you need to check before the form is sent, I think the only way is to
place onclick intrinsic events on the button elements. However, cancelling
the click event might not (I can't remember) stop the form submission, if
that was your intention.

Mike
[1] Either <input ... type="submit"> or <button ...
type="submit">. ..</button>

--
Michael Winter
M.******@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #3
That worked great, thanks. I should have mentioned but I need to do it with
type="image" and it does not work the same. Any work arounds?

<input type="image" SRC="/image/shipcomplete.gi f" border="0" alt="Shipment
Complete" name="action" value="Shipment Complete">
<input type="image" SRC="/image/addnextcarton.g if" border="0" alt="Add Next
Carton" name="action" value="AddNextC arton">

result is:
ACTION.Y=9
ACTION.X=67

when either buton is used.

Thanks,Adrian

"Michael Winter" <M.******@bluey onder.co.invali d> wrote in message
news:op******** ******@news-text.blueyonder .co.uk...
On Tue, 20 Jan 2004 22:56:04 +0000, David Dorward <do*****@yahoo. com>
wrote:
Adrian wrote:
I need to have 2 submit buttons in one form calling the same page. I
just
need to know which was used.
<input type="submit" name="s" value="1">
<input type="submit" name="s" value="1">

<?php

print $_REQUEST['s'];

?>

No need for JavaScript.


I assume that the values for the two buttons were supposed to be

different?
To the OP: If the submit button[1] has a name and value, that pair will be
sent with the rest of the data on submission. If there is more than one
button, only the clicked button will have its name/value pair sent. This
will allow you to check which button was pressed server-side.

If you need to check before the form is sent, I think the only way is to
place onclick intrinsic events on the button elements. However, cancelling
the click event might not (I can't remember) stop the form submission, if
that was your intention.

Mike
[1] Either <input ... type="submit"> or <button ...
type="submit">. ..</button>

--
Michael Winter
M.******@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

Jul 20 '05 #4
On Tue, 20 Jan 2004 16:43:50 -0800, Adrian <ad****@nocrapp lease.ascc.com>
wrote:
That worked great, thanks. I should have mentioned but I need to do it
with type="image" and it does not work the same. Any work arounds?


You could do one of two things.

1) Name the buttons differently. You could then check for the presence of
either name, rather than one name and two different values[1].
2) Use the BUTTON element, and place an IMG element inside it. This will
keep the standard functionality, but it is rendered horribly by Internet
Explorer. By contrast, it looks quite nice in Opera, and the button can be
styled so that you can't even see it (IE ignores the same styling). I
don't know how it will look in Mozilla and Netscape, but probably a lot
better than IE.

Mike

[1] As you've probably found, you'll get name/value pairs of the form
"name.x=nn" and "name.y=nn" where "nn" is the co-ordinates of the click,
and "name" is the name of the control.

--
Michael Winter
M.******@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #5
"Adrian" <ad****@nocrapp lease.ascc.com> wrote in message
news:bu******** **@news.tdl.com ...
That worked great, thanks. I should have mentioned but I
need to do it with type="image" and it does not work the
same. Any work arounds?

<input type="image" SRC="/image/shipcomplete.gi f"
border="0" alt="Shipment Complete" name="action"
value="Shipment Complete">
<input type="image" SRC="/image/addnextcarton.g if"
border="0" alt="Add Next Carton" name="action"
value="AddNextC arton">

result is:
ACTION.Y=9
ACTION.X=67


With <input type="image"> you get two name/value pairs instead of one
and the value isn't necessarily useful. If the two INPUT fields had
different names you would only get the name/value pairs from the button
click on so the presence of (either on of) those name/value pairs,
combined with the absence of either of the others would still tell you
which INPUT was used.

Also, you have named your INPUT elements "action" and that is a bad
habit as forms already have an action property and that property will be
overwritten by any form controls with a corresponding name. Rendering
that form property unscriptable (at minimum). It is best no to use
names/ids for form controls that correspond with any of the form's
property names, but as JavaScript is case sensitive that is not
difficult to achieve, initial capitals will do.

Richard.
Jul 20 '05 #6

If you really want to use javascript for this ...

<script language="javas cript">
function whichButton(but tonNumber) {
document.forms['myForm']['myButton'].value = buttonNumber;
}
</script>

<input type="submit" onClick="whichB utton('1');>
<input type="submit" onClick="whichB utton('2');>
I think this should work fine ... but I would use non javascript
examples first ... always ... html/ server-side obviously more
reliable.

Brynn
On Tue, 20 Jan 2004 13:55:20 -0800, "Adrian"
<ad****@nocrapp lease.ascc.com> wrote:
I need to have 2 submit buttons in one form calling the same page. I just
need to know which was used. Being able to pass a hidden form input for
each would be ideal. How can I do this??

Thanks!,Adri an


Brynn
www.coolpier.com

I participate in the group to help give examples of code.
I do not guarantee the effects of any code posted.
Test all code before use!
Jul 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
4281
by: Niall Linden | last post by:
i have a form with lots of data, and when they click on a button it calls some javascript which sets values in hidden fields then posts to itself (usual stuff) now the problem is that i would like to bring the page back to the same spot after the submit (as its very long) Ive added anchors to each button but if i add a the anchor tag to the action part of the form, im always one click behind, ie it jumps to the one I clicked on...
10
19354
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is able to fill that one out just fine. The second form is multipart/form-data. Unfortunately, I haven't been able to fill that out in a way that makes the server happy. I set up a copy of this form at my web site so that I could see exactly what a...
9
1962
by: Eric George | last post by:
Hi, Has anyone had any success using jscript submit method in their VS.NET projects? For example I have some client processing in a script function then call <form name>.submit(); This won't work. It does however work in a hand coded html or aspx page.
1
1575
by: Perry van Kuppeveld | last post by:
Hi, I would like to submit a form through scripting, and still retrieve the click event on the server. See code below to test some stuff. Create a C# webapplication and replace the WebForm1 class with the code below. While running the program, give the textarea the focus and press enter. See the dif with clicking submit.
5
17713
by: Navillus | last post by:
Hey gang, I have a login form that is empty by default, but can be filled with values from a previous form: <input type=text maxlength="40" size="40" name="user" value="`usr`"> <input type=password maxlength="8" name="password" value="`pss`"> where usr and pss are sent from the previous form.
1
2715
by: Ibrahim. | last post by:
Hi, I have a login page, the problem I'm facing is like this; 1. Login page with submit button (being default button); 2. When first time the page is submitted then submit code is called. 3. Again when page refresh is done by (f5) then submit button is fired implicitly.
5
5701
by: Simon Benson | last post by:
Probably a fairly simple problem but one that's been plaguing me for a couple of days... can anyone help? I have a classic ASP page with a number of text boxes which are updatable. For convenience I want to add 'tabs' at the top of the page (like a card index) as the data to be displayed is split into specific groups (client, company, preferences, events). How do I update any changes to the data and switch to a different page - at
15
4958
by: ABC | last post by:
Hi, I have a problem with Double submission in html forms. I am using PHP as the server side scripting language, i have found a means to capture the second form submission while the first form submission is still in-progress. Basically, i can use sessions to check if the first submission is active and reject subsequent submits. ***I do not want to try any client side solution(such as disabling submit button) as hitting F5 on the...
4
5511
by: j1dopeman | last post by:
Hi, I'd like to use a button to save and then submit a form. I can set the onlick of the button to mahButton_click or submit, but I can't figure out how to do both. It looks like c# can't call a form's submit. I've found how to post programatically, but I need to use the form's target attribute so that the response goes into another frame, and I can't figure out how to do that programatically.
0
8975
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8801
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9516
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9219
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8229
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6774
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4840
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2768
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2200
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.