繁体   English   中英

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

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

如何在提交后实现确认模式窗口。 我可以从PHP表单将数据插入数据库,但问题是它重定向到另一个页面。 我在表格中写的价值仍然存在。 我想保持在同一页面只使用确认模式窗口,表格将刷新而不是整个页面。

<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>

通过ajax发布您的表单。 见下文

$( "#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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM