<i id='IaG37'><tr id='IaG37'><dt id='IaG37'><q id='IaG37'><span id='IaG37'><b id='IaG37'><form id='IaG37'><ins id='IaG37'></ins><ul id='IaG37'></ul><sub id='IaG37'></sub></form><legend id='IaG37'></legend><bdo id='IaG37'><pre id='IaG37'><center id='IaG37'></center></pre></bdo></b><th id='IaG37'></th></span></q></dt></tr></i><div id='IaG37'><tfoot id='IaG37'></tfoot><dl id='IaG37'><fieldset id='IaG37'></fieldset></dl></div>
    <bdo id='IaG37'></bdo><ul id='IaG37'></ul>
  • <tfoot id='IaG37'></tfoot>

    <legend id='IaG37'><style id='IaG37'><dir id='IaG37'><q id='IaG37'></q></dir></style></legend>

      <small id='IaG37'></small><noframes id='IaG37'>

        表单提交前的引导模式

        时间:2023-06-21
            <tfoot id='a2wOh'></tfoot>

            • <bdo id='a2wOh'></bdo><ul id='a2wOh'></ul>
                <tbody id='a2wOh'></tbody>

              1. <legend id='a2wOh'><style id='a2wOh'><dir id='a2wOh'><q id='a2wOh'></q></dir></style></legend>

                <small id='a2wOh'></small><noframes id='a2wOh'>

                1. <i id='a2wOh'><tr id='a2wOh'><dt id='a2wOh'><q id='a2wOh'><span id='a2wOh'><b id='a2wOh'><form id='a2wOh'><ins id='a2wOh'></ins><ul id='a2wOh'></ul><sub id='a2wOh'></sub></form><legend id='a2wOh'></legend><bdo id='a2wOh'><pre id='a2wOh'><center id='a2wOh'></center></pre></bdo></b><th id='a2wOh'></th></span></q></dt></tr></i><div id='a2wOh'><tfoot id='a2wOh'></tfoot><dl id='a2wOh'><fieldset id='a2wOh'></fieldset></dl></div>
                  本文介绍了表单提交前的引导模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我是模态框的新手,我有一个表单,当用户单击提交时,它会显示一个模态框,确认用户是否要提交,模态框还包含来自表单字段的用户输入.我在整个互联网上搜索,但找不到适合我需要的那个.我所看到的只是他们标记了点击事件以在链接上打开模式.我有一个输入类型提交.你能举出例子或想法吗?谢谢!这是我的示例表单.

                  I'm new to Modals, I have a Form and when the user clicks submit, It will show a Modal confirming if the user wants to submit, the modal also contains the user input from the form fields. I searched all over the internet but can't find the right one on my needs. And all I see is that they tag the click event to open modal on a a link. i have a input type submit. Can you give examples or ideas? Thanks! Here's my sample form.

                  <form role="form" id="formfield" action="inc/Controller/OperatorController.php" method="post"  enctype="multipart/form-data" onsubmit="return validateForm();">
                  <input type="hidden" name="action" value="add_form" /> 
                  
                         <div class="form-group">
                           <label>Last Name</label><span class="label label-danger">*required</span>
                           <input class="form-control" placeholder="Enter Last Name" name="lastname" id="lastname">
                         </div>
                  
                          <div class="form-group">
                            <label>First Name</label><span class="label label-danger">*required</span>
                            <input class="form-control" placeholder="Enter First Name" name="firstname" id="firstname">
                         </div>
                  
                    <input type="submit" name="btn" value="Submit" id="submitBtn" class="btn btn-default" data-confirm="Are you sure you want to delete?"/>
                    <input type="button" name="btn" value="Reset" onclick="window.location='fillup.php'" class="btn btn-default" data-modal-type="confirm"/>
                  </form>
                  

                  推荐答案

                  所以,如果我做对了,点击一个按钮,你想打开一个模式,列出用户输入的值,然后提交它.

                  So if I get it right, on click of a button, you want to open up a modal that lists the values entered by the users followed by submitting it.

                  为此,您首先将 input type="submit" 更改为 input type="button" 并添加 data-toggle="modal" 数据-target="#confirm-submit" 以便在您单击它时触发模态:

                  For this, you first change your input type="submit" to input type="button" and add data-toggle="modal" data-target="#confirm-submit" so that the modal gets triggered when you click on it:

                  <input type="button" name="btn" value="Submit" id="submitBtn" data-toggle="modal" data-target="#confirm-submit" class="btn btn-default" />
                  

                  接下来,模态对话框:

                  <div class="modal fade" id="confirm-submit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                      <div class="modal-dialog">
                          <div class="modal-content">
                              <div class="modal-header">
                                  Confirm Submit
                              </div>
                              <div class="modal-body">
                                  Are you sure you want to submit the following details?
                  
                                  <!-- We display the details entered by the user here -->
                                  <table class="table">
                                      <tr>
                                          <th>Last Name</th>
                                          <td id="lname"></td>
                                      </tr>
                                      <tr>
                                          <th>First Name</th>
                                          <td id="fname"></td>
                                      </tr>
                                  </table>
                  
                              </div>
                  
                              <div class="modal-footer">
                                  <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                                  <a href="#" id="submit" class="btn btn-success success">Submit</a>
                              </div>
                          </div>
                      </div>
                  </div>
                  

                  最后,一点点 jQuery:

                  Lastly, a little bit of jQuery:

                  $('#submitBtn').click(function() {
                       /* when the button in the form, display the entered values in the modal */
                       $('#lname').text($('#lastname').val());
                       $('#fname').text($('#firstname').val());
                  });
                  
                  $('#submit').click(function(){
                       /* when the submit button in the modal is clicked, submit the form */
                      alert('submitting');
                      $('#formfield').submit();
                  });
                  

                  您尚未指定函数 validateForm() 的作用,但基于此,您应该限制您的表单被提交.或者您可以在表单的按钮 #submitBtn 上运行该功能,然后在检查验证后加载模式.

                  You haven't specified what the function validateForm() does, but based on this you should restrict your form from being submitted. Or you can run that function on the form's button #submitBtn click and then load the modal after the validations have been checked.

                  演示

                  这篇关于表单提交前的引导模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何跳转到浏览器页面顶部 下一篇:未知的提供者:$modalProvider &lt;- AngularJS 的 $modal 错误

                  相关文章

                  <small id='QCo8j'></small><noframes id='QCo8j'>

                  <tfoot id='QCo8j'></tfoot>
                  <i id='QCo8j'><tr id='QCo8j'><dt id='QCo8j'><q id='QCo8j'><span id='QCo8j'><b id='QCo8j'><form id='QCo8j'><ins id='QCo8j'></ins><ul id='QCo8j'></ul><sub id='QCo8j'></sub></form><legend id='QCo8j'></legend><bdo id='QCo8j'><pre id='QCo8j'><center id='QCo8j'></center></pre></bdo></b><th id='QCo8j'></th></span></q></dt></tr></i><div id='QCo8j'><tfoot id='QCo8j'></tfoot><dl id='QCo8j'><fieldset id='QCo8j'></fieldset></dl></div>

                    1. <legend id='QCo8j'><style id='QCo8j'><dir id='QCo8j'><q id='QCo8j'></q></dir></style></legend>
                      • <bdo id='QCo8j'></bdo><ul id='QCo8j'></ul>