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
  • 72,188
  • 19
  • 145
  • 210
Rohan Kumar
  • 39,838
  • 11
  • 73
  • 103

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
  • 45,891
  • 11
  • 86
  • 90