php - 单击相同的按钮打开模型,然后提交表单

标签 php javascript jquery css twitter-bootstrap

请帮助我:

我有一个带有提交按钮的表单。现在我想在这个按钮的点击事件上打开一个模式窗口。在模式中,我需要显示一个文本框,用于使用 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/

相关文章:

PHP Laravel 错误 : Object of class stdClass could not be converted to string

php - 如何将php多维数组数据存储到他们领域的数据库中

php - 我的网站在庞大的数据库中搜索数据。我应该使用 Lucene 来搜索还是自己编写算法?

javascript - 检测任何插入电子邮件地址或电话号码的尝试

javascript - 我应该如何在图像上添加标签?

c# - 制作脚本从页面下载所有 Mp3 文件

javascript - jquery/javascript 缓存问题

jquery - 将自定义错误放置与成功相结合不起作用 jquery 验证插件

jquery - 将 JSON 与 ASP.NET VB 结合使用

javascript - 使用 Angularjs 在动态列表项中添加事件 stopPropagation