简体   繁体   English

如何获取数据多复选框jQuery显示模式引导

[英]How to get data multi checkbox jquery show modal bootstrap

I want show data multi select checkbox and show data from database on modal bootstrap ? 我要显示数据多选择复选框并在模态引导程序上显示数据库中的数据吗?

index(PHP) 索引(PHP)

Javascript Code JavaScript代码

<script type="text/javascript">
$(document).ready(function()
{
    $("#btnDetail").click(function()
    {
        $('#modalForm').modal('show').on('shown.bs.modal',function()
        {
            var data = $("#data").val();
            $.post('page/user/detail_user.php',
            {
                id_data:$(this).attr(data)
            },
            function()
            {
                $('.modal-body').html(data);
            });
        });     
    });
});
</script>

Data User 资料使用者

<table width="100%" border="1">
    <tbody>
        <tr>
          <td width="3%" align="center">&nbsp;</td>
          <td width="97%" align="center">NAME</td>
        </tr>
        <?php
        $qry = mysql_query("SELECT * FROM t_users");
        while($data = mysql_fetch_array($qry))
        {
        ?>
            <tr>
              <td align="center"><input type="checkbox" name="data[]" id="data[]" value='<?php echo $data['id']?>'></td>
              <td><?php echo $data['name']?></td>
            </tr>
        <?php
        }
        ?>
    </tbody>
</table>
<button id='btnDetail' name='btnDetail'>Detail User</button>

Modal 模态

<div class="modal fade" id="modalForm" name='modalForm' tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title blue" id="myModalLabel"></h4>
            </div>
            <div class="modal-body">
            </div>
            <div class="modal-footer">
            </div>
        </div>
    </div>
</div>

Detail User(PHP) 详细用户(PHP)

<?php
 $id = $_POST['id_data'];

$qry = mysql_query("SELECT * FROM t_users WHERE id='$id'");
while($data = mysql_fetch_array($qry))
{
?>
<table width="100%" border="1">
  <tbody>
    <tr>
        <th colspan='3'>
            Detail Data Users
        </th>
    </tr>
    <tr>
      <td>ID</td>
      <td>NAME</td>
      <td>STATUS</td>
    </tr>
    <tr>
      <td><?php echo $data['id']?></td>
      <td><?php echo $data['name']?></td>
      <td><?php echo $data['status']?></td>
    </tr>
  </tbody>
</table>

<?php
}
?>

Scenario : 场景:
When button Detail User is click run Jquery and value checkbox and then send to modal bootstrap, then post from jquery run code php to show result data from database on modal bootstrap. 当单击按钮Detail User时,请运行Jquery and value复选框,然后发送到模式引导程序,然后从jquery运行代码php发布以显示模式引导程序中来自数据库的结果数据。

Here are hints to fix the problem : 这是解决问题的提示:

  1. ID in HTML shall be unique. HTML中的ID必须是唯一的。 (Not as the id "data[]" for all checkboxes) (并非所有复选框的ID为“ data []”)
  2. this is contextual. this是上下文。 So, when you use this in a bootstrap function, it probably (I would have to ensure) doesn't mean the previous jQuery function. 因此,当您在引导函数中使用this函数时,它(我必须确保)可能并不意味着先前的jQuery函数。
  3. You should manage retrieving the values of all the checked boxes. 您应该设法检索所有复选框的值。
  4. The PHP code should use the IN operator for the ID instead. PHP代码应使用IN运算符作为ID。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Bootstrap / JQuery:无法显示模式 - Bootstrap/JQuery: Cannot get modal to show 如何从 django model 获取数据并将其显示到引导模式弹出窗口中? - How to get data from a django model and show it into a bootstrap modal popup? 获取数据属性的值并在Bootstrap中以模式显示 - Get value of a data attribute and show it in a modal in Bootstrap 如何使用jQuery获取数据以引导3模态形式 - How to get data to bootstrap 3 modal form using jquery 如何从输入字段模态引导程序中获取值并使用 jquery 将值显示到同一模态中的另一个输入字段? - How to get value from input field modal bootstrap and show the value to another input field in the same modal with jquery? 从 thymeleaf 获取数据到模态引导程序 jquery - Get data from thymeleaf to a modal bootstrap, jquery 如何在模态内单击按钮时使用jQuery或javascript获取引导模式的数据值? - How to get data values of a bootstrap modal using jQuery or javascript on clicking button inside the modal? jQuery .load()bootstrap modal和show - jQuery .load() bootstrap modal and show 如何在使用 Modal Bootstrap PHP Mysql 时获取单选和复选框值 - How to get radio and checkbox value in using Modal Bootstrap PHP Mysql 如何使用 ajax-jquery 使用 PHP-CodeIgniter 将选定的复选框数据设置为模态 - How can use ajax-jquery to get selected checkbox data to modal using PHP-CodeIgniter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM