multi-submit button: identify which submit button clicked

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • webster5u
    New Member
    • Jan 2008
    • 28

    multi-submit button: identify which submit button clicked

    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?
  • RamananKalirajan
    Contributor
    • Mar 2008
    • 608

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

    Regards
    Ramanan Kalirajan

    Comment

    • webster5u
      New Member
      • Jan 2008
      • 28

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

      Code:
      <form action="..." method="..." onSubmit="validatetion(this)">
      
      <input ...
      <input type="submit" value="search" name="srh">
      <input type="submit" value="update" name="up">
      <input type="submit" value="delete" name="del">
      </form>
      Last edited by acoder; May 22 '09, 08:50 AM. Reason: Added [code] tags

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        He was referring to adding an onclick to the submit buttons:
        Code:
        <input type="submit" value="search" name="srh" onclick=" return validateSearch()">
        <input type="submit" value="update" name="up" onclick="return validateUpdate()">
        <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.

        Comment

        Working...