我想顯示數據多選擇複選框,並顯示模式引導數據庫中的數據?如何獲取數據多複選框jquery show modal bootstrap
指數(PHP)
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>
數據用戶
<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>
模態
<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>
詳細信息用戶(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
}
?>
場景:
當按鈕詳細信息用戶在點擊運行jQuery和值複選框,然後發送到模態引導,然後從jQuery的運行代碼的PHP發佈到顯示模態引導數據庫中的結果數據。
你能否簡單地總結一下,說明什麼可行,哪些不行。我很想知道你想要什麼,但爲了幫助別人的人,最好有(如果可能的話)明確的問題。 –
感謝您的幫助,我的問題是如何在數據庫中顯示數據到模態引導選中的複選框?,謝謝 –