gpt4 book ai didi

javascript - 将 PHP 值传递给 Twitter Bootstrap 模式

转载 作者:行者123 更新时间:2023-12-03 11:50:53 24 4
gpt4 key购买 nike

这是我的代码。如何获取 ['ADMINISTRATOR_ID'] 的值并将其传递到模式框。

我对这个 View 有点陌生 - 联系人是我的模式框。我应该使用 get 或 post 哪种方法?

<table class="table table-condensed">
<tbody>
<?php foreach ($td_admins as $row) : ?>
<tr>
<td>
<?=$row[ 'ADMINISTRATOR_ID'];?>
</td>
<td>
<?=$row[ 'FIRSTNAME'];?>
<?=$row[ 'LASTNAME'];?>
</td>
<td> <a href="#view_contact" class="btn btn-info btn-xs view" data-id="<?=$row['ADMINISTRATOR_ID'];?>" data-toggle="modal">View</a>
<a href="#" class="btn btn-danger btn-xs">Delete</a>

</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<div class="modal fade" id="view_contact" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<p>Admin row number:
<?php echo $_POST[ 'id'];?>
</p>
</div>
<div class="modal-footer"> <a class="btn btn-default" data-dismiss="modal">Close</a>

</div>
</div>
</div>
</div>

最佳答案

要在 Bootstrap 模式中绑定(bind)值,您必须监听 Bootstrap 事件并在其中执行您想要的操作。您可以通过bootstrap documentation查看这些事件列表.

<table class="table table-condensed">
<tbody>
<?php foreach ($td_admins as $row) : ?>
<tr>
<td>
<?=$row[ 'ADMINISTRATOR_ID'];?>
</td>
<td>
<?=$row[ 'FIRSTNAME'];?>
<?=$row[ 'LASTNAME'];?>
</td>
<td> <a href="#view_contact" class="btn btn-info btn-xs view" data-id="<?=$row['ADMINISTRATOR_ID'];?>" data-toggle="modal">View</a>
<a href="#" class="btn btn-danger btn-xs">Delete</a>

</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<div class="modal fade" id="view_contact" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<p>Admin row number:
<?php echo $_POST[ 'id'];?>
</p>
<p>Admin Id:
<span id="admin_id"></span>
</p>
</div>
<div class="modal-footer"> <a class="btn btn-default" data-dismiss="modal">Close</a>

</div>
</div>
</div>
</div>
<script type="text/javascript">
$('#view_contact').on('show.bs.modal', function (e) { // depend on vary your bootstrap version
var adminId = $('#admin_id').attr('data-id');
$('#admin-id').html(adminId);
});
</script>

关于javascript - 将 PHP 值传递给 Twitter Bootstrap 模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25840911/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com