textID.name = "the name u want"

解决方案 »

  1.   

    建议尽量不要改对象的name。否则极易引起混淆,请运行下面的代码。并注意alert出来的内容以及提交后地址栏上的name<HTML>
    <HEAD>
    <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
    <TITLE></TITLE>
    </HEAD>
    <BODY>
    <form method="get">
    <INPUT type="text" id=text1 name=text1>
    <INPUT type="submit" value="Submit" id=submit1 name=submit1>
    </form>
    </BODY>
    </HTML>
    <SCRIPT LANGUAGE=javascript>
    <!--
    document.all.text1.name="text2";
    alert(document.all.text1.name);
    alert(document.all.text1.outerHTML);
    //-->
    </SCRIPT>
      

  2.   

    NAME Attribute | name Property--------------------------------------------------------------------------------Sets or retrieves the name of the control, book, or application.SyntaxHTML <ELEMENT NAME = sName... >  
    Scripting object.name [ = sName ] Possible ValuessName String that specifies or receives the name. The property is read/write. The property has no default value.Expressions can be used in place of the preceding value(s), as of Microsoft&reg; Internet Explorer 5. For more information, see Dynamic Properties.ResWhen submitting a FORM, use the name property to bind the value of the control. The name is not the value displayed for the INPUT type=button, INPUT type=reset, and INPUT type=submit input types. The internally stored value, not the displayed value, is the one submitted with the form.Microsoft&reg; JScript&reg; allows the name to be changed at run time. This does not cause the name in the programming model to change in the collection of elements, but it does change the name used for submitting elements.In Microsoft&reg; Internet Explorer 5, the NAME attribute cannot be set at run time on A elements dynamically created with the createElement method. To create an A element with a name attribute, include the attribute and value when using the createElement method, or use the innerHTML property.再做一次人肉msdn......