两个表单一个提交按钮javascript

时间:2015-03-02 20:10:33

标签: javascript forms

无法使用单个提交按钮提交这两个表单。我尝试使用javascript,但没有工作。

有人可以帮我解决这个问题吗?

            <form id="batting" name="form1" method="post" action="">
            <input type="checkbox" name="batsman[]" value="1" /> <?php echo $bat1; ?><br />
            <input type="checkbox" name="batsman[]" value="2" /> <?php echo $bat2; ?><br />
            <input type="checkbox" name="batsman[]" value="3" /> <?php echo $bat3; ?><br />
            <input type="checkbox" name="batsman[]" value="4" /> <?php echo $bat4; ?><br />
            <input type="checkbox" name="batsman[]" value="5" /> <?php echo $bat5; ?><br />
            <input type="checkbox" name="batsman[]" value="6" /> <?php echo $bat6; ?><br />
            <input type="checkbox" name="batsman[]" value="7" /> <?php echo $bat7; ?><br /><br />
            </form>

            <form id="bowling" name="form2" method="post" action="">
            <input type="checkbox" name="bowler[]" value="1" /> <?php echo $bow1; ?><br />
            <input type="checkbox" name="bowler[]" value="2" /> <?php echo $bow2; ?><br />
            <input type="checkbox" name="bowler[]" value="3" /> <?php echo $bow3; ?><br />
            <input type="checkbox" name="bowler[]" value="4" /> <?php echo $bow4; ?><br />
            <input type="checkbox" name="bowler[]" value="5" /> <?php echo $bow5; ?><br /><br />
            </form>
            <input type="button" value="Click Me!" onclick="submitForms()" />

            <script type="text/javascript">

            //Syntax: checkboxlimit(checkbox_reference, limit)
            checkboxlimit(document.forms.batting, 2)

            //Syntax: checkboxlimit(checkbox_reference, limit)
            checkboxlimit(document.forms.bowling, 1)

            submitForms = function(){
                document.forms["form1"].submit();
                document.forms["form2"].submit();
            }

            </script>

0 个答案:

没有答案