js总结(11)一个页面同时提交多个form表单的实施

父页面的代码

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>Index</title>
       <script src="js/jquery-1.9.min.js"></script>
    </head>
    <body>
        <iframe src="form.php" width="800px" height="600px"></iframe>
        <iframe src="form.php" width="800px" height="600px"></iframe>
        <iframe src="form.php" width="800px" height="600px"></iframe>
        <iframe src="form.php" width="800px" height="600px"></iframe>
        <iframe src="form.php" width="800px" height="600px"></iframe>
        <iframe src="form.php" width="800px" height="600px"></iframe>
        <button>aa</button>
    </body>
     <script type="text/javascript">
            function submitAll(){
                var ifms = document.getElementsByTagName('iframe');
                for (var i = 0; i < ifms.length; i++) {
                    var win = (ifms[i].contentWindow || ifms[i]);
                    win.submitMe();
                }
            }
  $("button").click(
  	function () {
  	submitAll()
  	})
        </script>
</html>

  form表单的页面

 <script type="text/javascript">
            function submitMe(){
                document.getElementById('testForm').submit();
            }
            function submitAll(){
                window.parent.submitAll();
            }
        </script>

  

猜你喜欢

转载自www.cnblogs.com/nice2018/p/11393532.html
今日推荐