请帮助我:
我有一个带有提交按钮的表单。现在我想在这个按钮的点击事件上打开一个模式窗口。在模式中,我需要显示一个文本框,用于使用 2 个按钮在数据库中插入内容:取消和推送。单击推送后,我希望将数据插入数据库并提交表单!!! 不知何故我无法实现这一目标
<form action="post_data.php" method="post">
<!-- some elements -->
<input type ="submit" value = "Push data">
</form>
我正在使用 bootstrap-modal.js 但我面临的问题是我的表单指向 x.php,现在如果我需要打开一个 Bootstrap 模型,那么我需要提供属性:href="mymodal_id"和 data-toggle="modal"用于我的提交按钮。如果我这样做,我的页面绝对什么都不做 :( :( 请帮忙 任何帮助将不胜感激。提前致谢
最佳答案
使用<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>
关于php - 单击相同的按钮打开模型,然后提交表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12387392/