Several submit buttons in a form

O

Otto Wyss

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
 
I

Ian Collins

Otto said:
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.
 
R

Randy Webb

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top