• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Determining which button was clicked?

 
Bartender
Posts: 1757
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have some JavaScript that, given the name of a button, I can call the appropriate JavaScript function (in the onClick()).

But, since I have multiple submit buttons on a form, I'd like to be able to have a single JavaScript function and then do different things in a single JavaScript button based on which submit button's name was clicked.

Is there a way to determine which button was clicked via the event model, DOM, or other way within a JavaScript function that's called by multiple submit buttons?

Thanks in advance.

Mike
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Mike London
Bartender
Posts: 1757
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Eric.

Are any of these type tips documented in any book you've written?

I can't seem to readily find them in any of the JS books I have.

Thanks again.

Mike
 
I'd appreciate it if you pronounced my name correctly. Pinhead, with a silent "H". Petite ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic