在模态内提交表单时,模态不应关闭

时间:2019-07-18 06:47:27

标签: php bootstrap-modal

*我在模态中有一个表格。

应该发生什么->     表单包含一个复选框列表,用户将选中该复选框,然后单击“提交”按钮,它应在下面显示选中的值(使用PhP完成),而不关闭模式。

发生了什么事>     单击提交按钮后,模态内的PhP(用于显示所选数据)将运行,但模态将关闭。同样,打开模态时,它会显示先前选择的数据。*

模式代码:->

<div class="modal-content">
                <div class="modal-header">
                  <button type="button" class="close" data-dismiss="modal">&times;</button>
                  <h4 class="modal-title">Modal Header</h4>
                </div>
                <div class="modal-body">
                  <section class="sel-ser">
                <form id="modalForm" method="POST">
                 <div class="flex-item">
                    <div>
                    <h3>Win</h3>
                        <div>
                            <input type="checkbox" name="win[]" id="win" value="Win1">Win1
                        </div>
                        <div>
                            <input type="checkbox" name="win[]" id="win" value="Wind2">Win2
                        </div>
                    </div>
                    <div>
                    <h3>Lin</h3>
                        <div>
                            <input type="checkbox" name="lin[]" id="lin" value="Lin1">Lin1
                        </div>
                        <div>
                            <input type="checkbox" name="lin[]" id="lin" value="Lin2">Lin2
                        </div>              
                    </div>
                </div><br><br>
                <input type="submit" name="submit2" value="submit"><br><br><br>
                </form>
            </section>
            <section class="sel-ser">
                <h4>Win Select:</h4>
**This PhP code is used to collect the checked values and print them.** 

                <?php
                if(isset($_POST['submit2'])){
                    if(isset($_POST['win'])) 
                    {
                        $name2 = $_POST['win'];
                        foreach ($name2 as $win)
                        {
                            echo $win."<br />";
                        }
                    }
                    else 
                    {
                        echo "You did not choose.";
                    }
                }
                ?> 
                <br><br><h4>Lin Select:</h4>
                 <?php
                 if(isset($_POST['submit2'])){
                    if(isset($_POST['lin'])) 
                    {
                        $name = $_POST['lin'];
                        foreach ($name as $lin)
                        {
                            echo $lin."<br />";
                        }
                    }
                    else 
                    {
                        echo "You did not choose.";
                    }
                 }
                ?>

            </section>
                    </div>

感谢您的帮助。

0 个答案:

没有答案