If the same JavaScript function is called from multiple onClick events, how can I find out which button called it?

Jayesh Nazre

Well pass a this parameter to the function being called then inside that function u can find out which button was clicked. Here is a sample piece of code.

<script language="javascript">
function test(p_this) {
	if (p_this.name == "b_1") {
		alert ("HI U clicked 1");
	} else if (p_this.name == "b_2") {
		alert ("HI U clicked 2");

<form name=frm_test id=frm_test>
<input type=button name=b_1 
  id=b_1 Value=Button1 onclick="test(this)">
<input type=button name=b_2 
  id=b_2 Value=Button2 onclick="test(this)">