变量是不能重命名的,另外,alert应该用小写

解决方案 »

  1.   

    <form name="f1">
    <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来访问自己
      

  2.   

    抱歉,名称的引用是在第一次生成dom时完成的.你可以重新注册名称引用啊这样就可以了
    window.BB = AA;
    AA.NAME = "BB";
    alert(BB.NAME)
    alert(AA.NAME)
      

  3.   

    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&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.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.
      

  4.   

    AA的name属性是可写的,注意是小写不是大写。
    但他只在提交的时候起作用,你无法在程序中使用BB来访问到这个对象。
    ----------------------------------------------------------------------
    Microsoft 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.
      

  5.   

    yacus(脊髓神经) 大侠:能不能再说得详细些,我这边运行好象通不过.fokker(独孤龙) 大侠:难道没有其他的办法了吗?
    因为我用的动态表单,每一行有个选择按钮.
    从其他画面设置这一行的值的.
    天哪, 我要疯掉了.
      

  6.   

    george_yingjun (竹子),你说得不清楚,把问题在描述的详细一些。
      

  7.   

    变量名是不可以改的
    但是,如果你只是要动态访问不同的元素,那是很简单的,如:
    假设你的网页里有五个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);  //这里换成你自己的处理
    }