Help coderanch get a
new server
by contributing to the fundraiser
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Triggering event

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was asked this question and did not have the answer.
Question
If you have a function that handles a particular event, for example, onClick, for all buttons in a form. How do you find out which button triggers the event in your function?
Does anyone know?
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It depends on the browser.
IE implicity passes an event object to any event handler and you can access its srcElement property.
Netscape doesn't pass that element implicitly, but you can force it by specifying it as a parameter to your handler. Since this doesn't hurt anything in IE, doing it this way will work in both browsers.

Then in your handler...

[ February 13, 2002: Message edited by: Bodie Minster ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic