0

警报警报(document.inform.cid);即将到来未定义

 <html>
     <head>
     <script type="text/javascript">
    var interval = window.setInterval(iterate, 5000);
    function iterate() {
    var myStringArray = ["user1", "user2"];
       iterate.arr = iterate.arr || myStringArray.slice(0);

        //if it still has elements left
        if(iterate.arr.length > 0) {
            document.inform.cid = iterate.arr.pop(); //remove the top one
            alert(document.inform.cid);
            document.inform.pwd = "xxxxxxxx";
            document.inform.target = iterate.arr.length; // a different target each time - length of the arr
            document.inform.submit();
        } else {
            window.clearInterval(interval); //no more left cancel it
        }
    };

    </script>
     </head>
     <body >
      <form name="inform"   target="newWin" action="https://www.google.co.in/">
     <input type="hidden" name="throttle" value="999" />
     <input type="text" name="cid"  />
     <input type="text" name="pw"  />
        <input type="submit" value="go" onclick="iterate()">
      </form>
     </body>
    </html>
4

1 回答 1

0

在您的代码中:

>  document.inform.cid = iterate.arr.pop();

请注意,这document.inform.cid是对 DOM 输入元素的引用,并且iterate.arr.pop()是字符串值。所以赋值是不兼容的。

我想你的意思是:

 document.inform.cid.value = iterate.arr.pop();

 --------------------^^^^^

如果你使用更正式的,那可能会更明显:

 document.forms['inform'].elements['cid'].value ...
于 2012-11-07T06:06:01.327 回答