1

I bind a function as a "click" handler for a button whose id and name are the same as the function's name. It gives an error that function is undefined and the function isn't run.

<input type="button" name="saveClientDetail" id="saveClientDetail" onclick="saveClientDetail();" value="Save"/>

The HTML containing this element is loaded using AJAX. The function saveClientDetail(); is defined in an external JS file. When you click the button, it gives the error "saveClientDetail() is undefined". If I change the function name then it doesn't generate the error. Why is it so?

outis
  • 75,655
  • 22
  • 151
  • 221
Rohan Kumar
  • 40,431
  • 11
  • 76
  • 106

1 Answers1

2

You have id,name , and also function with same 'saveClientDetail' name. And the browser could not distinguish which one you meant by saveClientDetail name when you wrote that.

Engineer
  • 47,849
  • 12
  • 88
  • 91