首页 > 解决方案 > 如何提交 php 表单和弹出 javascript 的值?

问题描述

我创建了一个 PHP 页面,其中包含一些表单信息,并且在表单末尾我有一个提交按钮。我知道如何使用 PHP post 方法从表单中获取所有用户输入。我的问题如下,如何创建一个在用户单击提交按钮后弹出的迷你弹出表单。弹出表单会询问用户提交信息是否紧急,用户只需在紧急或不紧急之间进行选择,然后单击迷你弹出表单中的按钮(“继续”)即可关闭弹出窗口up 并将用户输入的所有信息与弹出窗口一起发送到不同的 PHP 页面。有人可以指导这个问题吗?

我目前表格的源代码如下

 <?php include "includes/tasksheader.php"; ?>

    <link href="https://fonts.googleapis.com/css?family=Oleo+Script:400,700" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Teko:400,700" rel="stylesheet">
    <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">

<div class="main1">
            <div class="contact-section">
            <div class="container">

                <form>
                    <div class="col-md-6 form-line">
                        <div class="form-group">
                            <label for="exampleInputUsername">Social Ensuarance Number</label>
                            <input type="text" class="form-control" id="" placeholder="Ensuarance Number">
                        </div>
                        <div class="form-group">
                            <label for="exampleInputEmail">Land Regisrty Department</label>
                            <input type="email" class="form-control" id="exampleInputEmail" placeholder="Land Registry">
                        </div>  
                        <div class="form-group">
                            <label for="telephone">Income Tax Office</label>
                            <input type="tel" class="form-control" id="telephone" placeholder="Tax Office">
                        </div>
                        <div class="form-group">
                            <label for="telephone">Court</label>
                            <input type="tel" class="form-control" id="telephone" placeholder="Court">
                        </div>
                        <div class="form-group">
                            <label for="telephone">Limassol District Administration</label>
                            <input type="tel" class="form-control" id="telephone" placeholder="District Administration">
                        </div>
                        <div class="form-group">
                            <label for="telephone">Municipality</label>
                            <input type="tel" class="form-control" id="telephone" placeholder="Municipality">
                        </div>
                    </div>
                    <div class="col-md-6">
                       <div class="form-group">
                            <label for="exampleInputUsername">VAT Department</label>
                            <input type="text" class="form-control" id="" placeholder="VAT">
                        </div>
                        <div class="form-group">
                            <label for="exampleInputEmail">RCB Bank</label>
                            <input type="email" class="form-control" id="exampleInputEmail" placeholder="RCB Bank">
                        </div>  
                        <div class="form-group">
                            <label for="telephone">Hellenic Bank</label>
                            <input type="tel" class="form-control" id="telephone" placeholder="Hellenic Bank">
                        </div>
                        <div class="form-group">
                            <label for="telephone">Bank of Cyprus</label>
                            <input type="tel" class="form-control" id="telephone" placeholder="Bank of Cyprus">
                        </div>
                        <div class="form-group">
                            <label for="telephone">CDB Bank</label>
                            <input type="tel" class="form-control" id="telephone" placeholder="CDB Bank">
                        </div>
                        <div class="form-group">
                            <label for="telephone">Other</label>
                            <input type="tel" class="form-control" id="telephone" placeholder="Other">
                        </div>
                    </div>

                        <div class="form-group">

                            <label for ="description"> Message</label>
                            <textarea  class="form-control" id="description" placeholder="Enter Your Message"></textarea>

                        <div>

                            <button type="button" class="btn btn-default submit"><i class="fa fa-paper-plane" aria-hidden="true"></i>  Send Message</button>
                        </div>  
                        </div>                                              
                </form>
            </div>
            </div>
</div>

致谢

标签: javascriptphpjquery

解决方案


我猜你需要做以下事情:首先创建弹出表单(有两个按钮......)然后你需要在你的 javascript 文件中编写以下内容:

$('form').on("submit", function(e){
  e.preventDefault();
  $('popup').fadeIn();
  ...
}

或者

$('button').on("click", function(e){
  e.preventDefault();
  $('popup').fadeIn();
  ...
}

然后在您的弹出窗口中,您将再次需要preventDefault并按照您的意图做任何事情。我希望它有帮助:)


推荐阅读