Conflict between js function name and form element with the same name

Source: Internet
Author: User

When exporting an Excel file today, we used Form input den to differentiate export and search. At the beginning, The onClick event function name in js is the same as that in hidden. Result: The row of objects that call the function does not support this attribute.

I couldn't find the cause for a long time. At the beginning, I thought it was wrong to write a letter, only to find that the js function was not executed at all. Later, I was unable to directly call other functions and found that they were useful. I thought it was the reason for the function name and changed the function name. Then, change the id in input to the same function name, and an error is reported. The ThinkPHP template parsing bug was still thought before the following example was verified. As shown in the following example, the function name in Javascript cannot be the same as the id in the element.

For example:
Copy codeThe Code is as follows:
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> ceshi </title>
<Script>
Function ()
{
Document. getElementById ('A'). value = "test ";
Alert (document. getElementById ('A'). value );
Return false;
}
</Script>
</Head>
<Body>
<Form>
<Input type = "hidden" id = "a" name = "a" value = ""/>
<Input type = "button" value = "excel" onClick = "javascript: a ();"/>
</Form>
</Body>
</Html>

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; CIBA;. net clr 2.0.50727)
Timestamp: Thu, 27 Jan 2011 13:30:09 UTC

Message: the object does not support this attribute or method.
Row: 17
Character: 1
Code: 0
URI: file: // C:/Documents % 20and % 20 Settings/Administrator/desktop/test.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.