我遍历 forms[0] 中的变量,根据名称比较来找到那个变量,然后进行操作。
不知道还有没有其它办法。

解决方案 »

  1.   

    可以使用input的id
    <input id="xxx">
      

  2.   

    谢谢楼上的,我那里必须用名称,而且名称中必须有冒号,是 .NET 中服务器端吐出来的,不用冒号就有问题。
      

  3.   

    <form>
    <input type=text name="aaa:bbb" value="tttt">
    <input type=button onclick="return c()">
    </form>
    <script>
    function c()
    {
       alert(document.forms[0].elements["aaa:bbb"].value);
    }
      

  4.   

    <form>
    <input type=text name="aaa:bbb" value="tttt">
    <input type=button onclick="return c()">
    </form>
    <script>
    function c()
    {  alert(document.forms[0].elements["aaa:bbb"].value);
       alert(document.all("aaa:bbb").value);  
       alert(document.getElementsByName("aaa:bbb")[0].value);
    }
    </script>