你点button1触发的是upload()函数而不是add()函数。你的button2才是add()函数。

解决方案 »

  1.   

    <html>
    <body>
    <form name="form01" method=post action="test01.html">
    <input type="button" name="button1" value="button1" onClick="upload();">
    </form><form name="form02" method=post action="test02.html">
    <input type="file" name="file">
    <input type="button" name="button2" value="button2" onClick="add();" >
    </form></body>
    </html>
    <script language="javascript">
    function upload(){
    document.forms[1].file.click();
    document.form02.button2.click();
    }function add(){
    document.forms[1].submit();
    }
    </script>
      

  2.   

    兄弟不支持模拟提交,请放到iframe中提交
      

  3.   


    document.forms[1].file.click();是这句有问题,type=file 的 input 不允许你这样做,做了也没有最终效果。 
      

  4.   

    我这里测试是可以的啊,能转到test02.html
      

  5.   

    function upload(){
    document.forms[1].file.click();
    document.getElementById("button2").click();
    }
    -------------------------
    原因:你使用
    document.form02.button2.click();这句话想触发button2的click事件,其实这样是不对的,因为你使用document.form02.button2他调用的是表单对象,并非document对象,不信你试试:alert(document.form02.button2.value);这样是没问题的。如果想调用click,就只能通过document对象的形式,使用document.getElementById("button2"),或者document.all.button2来定位对象