用document.all.abc.value='1';这样来给一个form中的ID为abc赋值,但是问题是,如果表单中有两个重复ID均为abc怎么办?

解决方案 »

  1.   

    用document.all.abc.value='1';这样来给一个form中的ID为abc赋值,但是问题是,如果表单中有两个重复ID均为abc怎么办?
      

  2.   

    应该用不同的ID吗?但是表单当初设计的时候,用数组读出来就成了重复ID了。。再试试看能修改表单不
      

  3.   

    ID
    identity 表示唯一性,身份证号码一样
      

  4.   

    明白了
    那能问另外一个问题吗?ajax页面无法直接写<script></script>,那应该如何在后台页面输出js后,自动进行js赋值处理呢?
    比如asp处理页面中输出结果为:<script>document.all.abc.value="123";</script>这样在html中似乎无法用ajax来加载,如何自动的执行 document.all.abc.value="123";这句呢?
      

  5.   

    误导。
    页面上的id当然可以重复,如果重复获document.getElementById('youID')获得是的是一个array[]数组。
    如果是单id ,document.getElementById('youID')获得是对象object自动进行js赋值处理,可以使用eval(str);
    str是你的js处理字符串,
      

  6.   

    好像不能输出啊?我是不是写错了?
    html中的ajax代码:
    function getuser(str){
        xmlhttp.open('get',"getname.asp?tid=userid="+(str)+"&sn="+Math.random(),true);
        xmlhttp.onreadystatechange = function(){
            if(xmlhttp.readyState==4){
                document.getElementById("userinfo").innerHTML =unescape(xmlhttp.responseText);
            }
        }
        xmlhttp.setRequestHeader("If-Modified-Since","0");
        xmlhttp.send(null);
    }asp处理页面getname.asp:<%
    Response.Write("eval(document.writeln('OK');)")
    %>似乎html页面中只返回了eval(document.writeln('OK');)这一句而没有被执行。。
      

  7.   

    id可以重复,但是一般不这么做,如果有重复的ID,document.getElementById('youID')返回的应该是第一个匹配的元素吧!?
      

  8.   


    function getuser(str){
        xmlhttp.open('get',"getname.asp?tid=userid="+(str)+"&sn="+Math.random(),true);
        xmlhttp.onreadystatechange = function(){
            if(xmlhttp.readyState==4){
                document.getElementById("userinfo").innerHTML =unescape(xmlhttp.responseText);
            }
        }
        xmlhttp.setRequestHeader("If-Modified-Since","0");
        xmlhttp.send(null);    
    }楼主你上面那些写直接输出要显示的值就可以了,不要带js代码,如果带js代码的话<%
    Response.Write("alert(123)")
    %>
     xmlhttp.onreadystatechange = function(){
            if(xmlhttp.readyState==4){
                eval(xmlhttp.responseText);
            }
        }