By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,377 Members | 1,690 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,377 IT Pros & Developers. It's quick & easy.

multi-submit button: identify which submit button clicked

P: 28
Hi, i have a question about JavaScript. When we click a submit button from the form with multi-submit button. Can JavaScript detect which submit button has been submit?

I make a form with 3 submit button (select, update and delete) and i put validation javascript function in onSubmit event handler. May i apply different validation according to different submit button?
May 21 '09 #1
Share this Question
Share on Google+
3 Replies

P: 607
Sure, you can do that... You can have different validate function and onlick of the submit button u can validate form variables...

Ramanan Kalirajan
May 21 '09 #2

P: 28
form variable? Can you explain how it work?
if we take the code below as example, then what's variable name in Javascript.

Expand|Select|Wrap|Line Numbers
  1. <form action="..." method="..." onSubmit="validatetion(this)">
  3. <input ...
  4. <input type="submit" value="search" name="srh">
  5. <input type="submit" value="update" name="up">
  6. <input type="submit" value="delete" name="del">
  7. </form>
May 22 '09 #3

Expert Mod 15k+
P: 16,027
He was referring to adding an onclick to the submit buttons:
Expand|Select|Wrap|Line Numbers
  1. <input type="submit" value="search" name="srh" onclick=" return validateSearch()">
  2. <input type="submit" value="update" name="up" onclick="return validateUpdate()">
  3. <input type="submit" value="delete" name="del" onclick="validateDelete()">
Another option is to set a variable to the name of the button onclick and check for it within the validation function.
May 22 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.