0

请在这件事上给予我帮助 :

我有一个带有提交按钮的表单。现在我想在这个按钮的点击事件上打开一个模式窗口。在模式中,我需要显示一个文本框,用于在 DB 中插入带有 2 个按钮的内容:取消和推送。单击推送时,我希望将数据插入数据库并提交表单!不知何故我无法做到这一点

<form action="post_data.php" method="post">
  <!-- some elements -->
  <input type ="submit" value = "Push data">    
</form>

我正在使用 bootstrap-modal.js 但我面临的问题是我的表单指向 x.php,现在如果我需要打开引导模型,那么我需要提供属性:href="mymodal_id" 和 data-toggle="模态”为我的提交按钮。如果我这样做,我的页面绝对不会做任何事情:( :(请帮助任何帮助将不胜感激。在此先感谢

4

1 回答 1

3

使用 an<a>触发您的模态:

<a href="#myModal" role="button" class="btn" data-toggle="modal">Launch demo modal</a>

然后将您的提交和取消按钮放在该模式中:

<div class="modal" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel">Pushing to DB</h3>
    </div>
    <div class="modal-body">
        <p>You are going to push data</p>
    </div>
    <div class="modal-footer">
        <button type="button" class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
        <button type="submit" class="btn btn-primary" value="Push data">Push data</button>
    </div>
</div>
于 2012-09-12T12:46:59.057 回答