The problem of the js function name colliding with the form form element

  • 2020-03-30 02:19:30
  • OfStack

It took a long time to find out the reason. At the beginning, I always thought that I wrote a wrong letter, and then I found that the js function was not executed at all. Later, there is no way to directly call other functions, found useful, think is the reason for the function name, changed the function name is useful. Then I changed the id in the input to be exactly the same as the function name, and again I got an error. I thought it was a bug in ThinkPHP template parsing until the following example was validated. Because of the following example, it turns out that the function name in js cannot be the same as the id in the element.

The following cases:

<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
function a()
 return false;
<input type="hidden" id="a" name="a" value="" />
<input type="button" value="excel" onClick="javascript:a();"/>

Page error details

User agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident / 4.0; CIBA. CLR 2.0.50727)
Time stamp: Thu, 27 Jan 2011 13:30:09 UTC

Related articles: