无法在bootstrap中提交模态按钮

时间:2014-02-17 03:41:18

标签: javascript php jquery html twitter-bootstrap

我有一个表格,其中包含来自MySQL表格的行和一个删除按钮,可在提交前确认所需的操作。 模态工作正常,发布所有表单输入并在用户确认时提交,除了提交删除按钮的值,我知道它与模态有关。

我正在使用bootstrap 3并在此处对话框确认:http://myclabs.github.io/jquery.confirm/

我的php代码生成了这个html:


<script type="text/javascript" src="js/jquery.confirm.js"></script>
<form class="form-horizontal" role="form" action="myscript.php?id=1" method="post" id="myform">
<button id="del-1" name="del[1]" type="submit"><span class="glyphicon glyphicon-remove"></span></button>
    <label for="name-1"> Name</label><input type="text" name="name-1" value="Some name">
    <script>
        $(document).ready(function() {
        $("#del-1").confirm({
            title:"Delete Some name",
            text:"Are you sure?",
            confirm: function(button) {
                $('#myform').submit();
            },
            cancel: function(button) {
            },
            confirmButton: "Yes, delete!",
            cancelButton: "No"
            });
        });
    </script>
    <button id="del-2" name="del[2]" type="submit"><span class="glyphicon glyphicon-remove"></span></button>
    <label for="name-2"> Name</label><input type="text" name="name-2" value="Some othername">
    <script>
        $(document).ready(function() {
        $("#del-2").confirm({
            title:"Delete Some othername",
            text:"Are you sure?",
            confirm: function(button) {
                $('#myform').submit();
            },
            cancel: function(button) {
            },
            confirmButton: "Yes, delete!",
            cancelButton: "No"
            });
        });
    </script>
    <button type="submit" title="Edit names" name="edit">Edit names</button>
</form>

所以当我点击“编辑名称”按钮时,它会被提交给php,当我点击“是,删除!”按钮已发布但不发布值"del[1]" or "del[2]"(var_dump($_POST)),它只发布所有其他表单值。

当用户点击confirmButton时,如何从"del[x]"收到帖子?

0 个答案:

没有答案