[英]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"> </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">×</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 : 这是解决问题的提示:
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函数。 IN
operator for the ID instead. IN
运算符作为ID。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.