简体   繁体   English

在表单提交到数据库之后实现模式窗口并保持在同一页面上

[英]Implementing modal window after form submit to database and remain on the same page

How can I implement a confirmation modal window after after submitting . 如何在提交后实现确认模式窗口。 I can insert data into database from a PHP form , but the problem is it redirects to another page . 我可以从PHP表单将数据插入数据库,但问题是它重定向到另一个页面。 And the value I have written in form still remain . 我在表格中写的价值仍然存在。 I want to remain on the same page just use an confirmation modal window and the form will be refreshed not the whole page . 我想保持在同一页面只使用确认模式窗口,表格将刷新而不是整个页面。

<form role="form" action="db.php" method="post">
                                <div class="form-group">
                                    <label for="name">Name</label>
                                    <input type="text" class="form-control" id="name" placeholder="Your Full Name">
                                 </div>
                                 <div class="form-group">
                                    <label for="address">Delivery Address</label>
                                    <input type="text" class="form-control" id="address" placeholder="Address">
                                 </div>
                                 <div class="form-group">
                                    <label for="phone">Phone No</label>
                                    <input type="text" class="form-control" id="phone" placeholder="Phone No">
                                 </div>
                                  <div class="form-group">
                                    <label for="email">Email address</label>
                                    <input type="email" class="form-control" id="email" placeholder="Enter email">
                                  </div>
                                  <div class="form-group">
                                    <label for="exampleInputEmail1">Quantity</label>
                                    <select class="form-control" id="quantity">
                                      <option>1</option>
                                      <option>2</option>
                                      <option>3</option>
                                      <option>4</option>
                                      <option>5</option>
                                    </select>
                                  </div>
                                  <div class="form-group" >
                                    <label for="exampleInputEmail1">Expected Date</label>
                                     <input id="datepicker" />
                                  </div>


                                  <button type="submit" class="btn btn-default" >Submit</button>
                            </form>

Post your form via ajax. 通过ajax发布您的表单。 See below 见下文

$( "#formid" ).submit(function( event ) {
 event.preventDefault();

 $.ajax({
   url: 'db.php',
   type: 'POST',
   data:  $('#formid').serialize(),
   success: function(response) { 
   if(response == 'Success') {  
       $('#model_div_id').html("Success");
       $('#model_div_id').modal('show'); //twitter bootstrap modal  
   },

});

});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 单击表单上的提交后如何保持在同一页面上? - How to remain on the same page after clicking submit on a form? 在重定向到同一页面上提交表单后关闭模式 - close modal after submit of form on redirect to same page 表单提交后,如何防止页面刷新并使它保留在同一选项卡部分中 - After form submit how to prevent page refresh and make it to remain in same tab section 表单提交后重定向到同一页面中的锚点 - Redirect to anchor in same page after form submit 表单提交后,它将重定向到同一页面 - After form submit it redirects to same page 提交后回显表单并重新加载到同一页面上 - Echo form and reload on same page after submit 表单提交后,重定向回页面并显示模式 - After form submit redirect back to page and show a modal 在模式提交表单后更新值,无需重新加载即可更新页面 - update value after form submit in modal and update page without reload 仅在发布到同一页面的表单上单击提交后,才将数据发送到数据库 - Sending data to database only after submit has been clicked on a form that posts to same page 用户点击提交后,页面跳转到php文件。 它如何保留在 HTML 文件中并将表单信息提交到电子邮件? - After the user clicks submit, the page goes to the php file. How can it remain on the HTML file and submit the form information to the email?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM