Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Submit Buttons 1

Status
Not open for further replies.

Mighty

Programmer
Joined
Feb 22, 2001
Messages
1,682
Location
US
Hi Folks,

I have searched the forum looking for a solution to my problem but didn't find one. I have a form with two submit buttons. Both have the same name but have different values.

The reasoning behind this is that in my server side code (ASP) I check the value of the button (btnSubmit) and carry out different tasks depending on which one was clicked.

However, in my client side validation, I also need to find out which button was clicked because it will dictate what validation is carried out. Now I could just change them to standard buttons and call different functions when they are clicked.

At the moment they are both submit buttons and a validation form is called when the form is submitted. How can I check which button was pressed to fire the validation function??

Mighty
 
If you don't care about people with JavaScript disabled, or do server-side validation anyway, then you've answered your own question (make them standard buttons).

If you do care, then there are several ways to do this. One was covered last week when this same question was asked... another would be to have an onclick on the submit buttons which sets a variable which you can pick up on in the onsubmit handler to call one validation function or another.

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thanks Dan. I like the idea of the onClick setting the value of a variable - didn't think of that. It's on an intranet site so I know that everyone will have javascript enabled.

Mighty
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top