473,500 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Several submit buttons in a form

In a form I've several buttons which submits the form and I'd like to do
different checks in the onsubmit event handler. How can I find out which
button was activated?

<script type="text/javascript">
function checkInput (t) {
if (t. ...) return false;
return true;
}
....
<form name="test" onsubmit="return checkInput(this);" action="...
...
<input type="submit" name="send1" value="Text1">
<input type="submit" name="send2" value="Text2">

O. Wyss
--
Cross-platform applications:
http://wyoguide.sf.net/index.php?page=projectlist.php
Feb 13 '07 #1
2 2873
Otto Wyss wrote:
In a form I've several buttons which submits the form and I'd like to do
different checks in the onsubmit event handler. How can I find out which
button was activated?
You could add an onclick handler for each button.

--
Ian Collins.
Feb 13 '07 #2
Otto Wyss said the following on 2/13/2007 3:37 PM:
In a form I've several buttons which submits the form and I'd like to do
different checks in the onsubmit event handler. How can I find out which
button was activated?

<script type="text/javascript">
function checkInput (t) {
if (t. ...) return false;
return true;
}
...
<form name="test" onsubmit="return checkInput(this);" action="...
...
<input type="submit" name="send1" value="Text1">
<input type="submit" name="send2" value="Text2">

O. Wyss
<input type="hidden" name="submitButtonClicked">

<input type="submit" name="send1"
onclick="this.form.submitButtonClicked.value=this. name">

And then check the value of t.submitButtonClicked and it will tell you
which button was clicked.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Feb 13 '07 #3

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

Similar topics

2
2261
by: Colin Steadman | last post by:
I have two buttons on my form and need to know which was clicked. If I setup the buttons like this: <input type="submit" value="submit" name="submit_to_array"> <input type="submit"...
2
9574
by: ivanhoe | last post by:
All articles and tutorials I've seen on subject of forms say that if there's name and value for submit button(input tag with type="submit"), they'll get submitted along with the rest of the...
15
6538
by: M Smith | last post by:
I have a form I want to submit to itself. I want to be able to type in a list of numbers and submit the form and have that list show up on the same form under the text box I typed them into and...
15
2522
by: JR | last post by:
Hi. I hope someone out there who is more versed with JavaScript than I can help me with the following annoying problem. Here's the problem. I have a form with the following layout: Column A...
9
3970
by: Poker Man | last post by:
Hi, I know how to do Sumbit buttons in Forms, and I know how to do custom buttons in Javascript. What I can't seem to find is how to do custom Submit buttons using Javascript! Anybody out...
6
2406
by: wolfing1 | last post by:
how would I go doing it without javascript and using 'POST'? Having a page with a variable list of items in a shopcart, each item with its own 'remove' button. How could I do this without a...
5
2706
by: Chris | last post by:
I have a meetings section I'm developing on our intranet. Using PHP/MySQL. Meeting info and Meeting docs reside on 2 related tables in the db. Users may want to upload anywhere from 1 to 10 or...
8
1856
by: Kees de Winter | last post by:
Hi, On a form I have several submit-buttons, each of which should post its own set of variables (e.g. price and name of a product) to another page, e.g. an orderpage. There can only be one form,...
5
1896
by: Alex | last post by:
Hello, I hope I can explain this properly. I'm writing an application with a tabbed-based navigation, and a form which gets filled out by users will be split into 5 subtabs. What I need is...
0
7136
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
7018
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...
0
7232
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
5490
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
4611
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3106
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1430
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
672
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
316
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...

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.