MSDN关于name属性的解释: When 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 JScript® 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.The NAME attribute cannot be set at run time on elements dynamically created with the createElement method. To create an element with a name attribute, include the attribute and value when using the createElement method.
AA的name属性是可写的,注意是小写不是大写。 但他只在提交的时候起作用,你无法在程序中使用BB来访问到这个对象。 ---------------------------------------------------------------------- Microsoft JScript® 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.
<INPUT TYPE="TEXT" NAME="AA" id="aa" VALUE="1" size="20">
</form>
<SCRIPT LANGUAGE="JavaScript">
<!--
var str1="yingjXXyingjXX1234X";
while(str1.indexOf("XX") > 0) {
var index = str1.indexOf("XX");
str1=str1.substring(0, index) + "aa" + str1.substring(index+2);
}
alert(str1);
f1.aa.name="BB"
alert(f1.aa.name)
//-->
</SCRIPT>你不能用AA.name来访问自己
window.BB = AA;
AA.NAME = "BB";
alert(BB.NAME)
alert(AA.NAME)
When 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 JScript® 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.The NAME attribute cannot be set at run time on elements dynamically created with the createElement method. To create an element with a name attribute, include the attribute and value when using the createElement method.
但他只在提交的时候起作用,你无法在程序中使用BB来访问到这个对象。
----------------------------------------------------------------------
Microsoft JScript® 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.
因为我用的动态表单,每一行有个选择按钮.
从其他画面设置这一行的值的.
天哪, 我要疯掉了.
但是,如果你只是要动态访问不同的元素,那是很简单的,如:
假设你的网页里有五个span,
<span id="Span0">Span0</span>
<span id="Span1">Span1</span>
<span id="Span2">Span2</span>
<span id="Span3">Span3</span>
<span id="Span4">Span4</span>
你在脚本中可以写:
for (var i=0; i < 5; i++)
{
obj = document.all("Span" + i );
alert(obj.innerHTML); //这里换成你自己的处理
}