dongzhuo1930 2018-01-23 18:58
浏览 58

提交表单而不使用PHP更改选项卡窗格

I'm using Bootstrap 4 and I've created a two pane form; registration and sign in forms.

I know using AJAX is more suitable for such situations that it won't make the page refresh, however, I'm asking if there is any way of achieving that the page refreshes and previews the same pane using only PHP.

Form

Using PHP in the code. Is there any way that when I submit the form when in registration pane (the one on the right hand side), the page refreshes and stays in the same pane.

<!-- Tabs -->
        <nav class="register-nav">
            <div class="nav nav-tabs nav-justified" id="nav-tab" role="tablist">
                <a class="nav-item nav-link active" id="nav-signin-tab" data-toggle="tab" href="#nav-signin" role="tab">Sign in</a>
                <a class="nav-item nav-link" id="nav-signup-tab" data-toggle="tab" href="#nav-signup" role="tab">Create New Account</a>
            </div>
        </nav>
        <!-- Content of Tabs -->
        <div class="tab-content" id="nav-tabContent">
            <!-- Sign in Tab Pane -->
            <div class="tab-pane fade show active" id="nav-signin" role="tabpanel">
                <form action="" method="POST">
                    <div class="form-group">
                        <div class="row">
                            <div class="col-sm-6">
                                <a class="btn btn-block btn-social btn-facebook">
                                    <span class="fa fa-facebook"></span> Sign in with Facebook
                                </a>
                            </div>
                            <div class="col-sm-6">
                                <a class="btn btn-block btn-social btn-google">
                                    <span class="fa fa-google"></span> Sign in with Google
                                </a>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <input type="text" class="form-control" placeholder="Username / Email Address">
                    </div>
                    <div class="form-group">
                        <input type="password" class="form-control" placeholder="Password">
                    </div>
                    <div class="form-group text-center mt-5">
                        <input type="submit" class="btn btn-outline-info" value="Sign in">
                    </div>
                </form>
            </div>
            <!-- Sign Up Tab Pane -->
            <div class="tab-pane fade" id="nav-signup" role="tabpanel">
                <form action="" method="POST">
                    <div class="form-group">
                        <input type="text" class="form-control" placeholder="First name" required>
                    </div>
                    <div class="form-group">
                        <input type="text" class="form-control" placeholder="Last name" required>
                    </div>
                    <div class="form-group">
                        <input type="text" class="form-control" placeholder="Username" required>
                    </div>
                    <div class="form-group">
                        <input type="email" class="form-control" placeholder="Email Address" required>
                    </div>
                    <div class="form-group">
                        <input type="password" class="form-control" placeholder="Password" required>
                    </div>
                    <div class="form-group">
                        <input type="password" class="form-control" placeholder="Confirm Password" required>
                    </div>
                    <div class="form-check">
                        <input type="checkbox" class="form-check-input" required>
                        <label class="form-check-label">By registering to
                            <a href="index.html">velocity</a>, you agree to its
                            <a href="terms.html">terms and conditions</a>
                        </label>
                    </div>
                    <div class="form-group text-center mt-5">
                        <input id="register-btn" type="submit" class="btn btn-outline-success" value="Register" disabled>
                    </div>
                </form>
            </div>
        </div>
  • 写回答

2条回答 默认 最新

  • dongzhaobai5982 2018-01-23 19:03
    关注

    Add a hidden input with a value that indicaties which pane should open. When generating the form (with Php) decide which pane gets an active class based on this value in the $_POST array

    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么