我需要在调用弹出窗口时通过链接传递变量。添加像我这样的变量通常会使名称与弹出窗口不匹配。
这就是我所拥有的:
<a data-toggle="modal" href="#allMessages?id=<?php echo $job['job_id']; ?>" class="btn btn-warning btn-sm btn-icon">
<i class="fa fa-unlock-alt"></i>View All Messages
</a>
<div class="modal fade" id="allMessages" tabindex="-1" role="dialog" aria-labelledby="allMessages" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header success">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i></button>
<h4 class="modal-title">Reply</h4>
</div>
<?php
$getMessages = mysqli_query($mysqli,
"SELECT *
FROM messages
WHERE messages.job_id = $GET['id']
"
);
$messages = array();
while($message = mysqli_fetch_assoc($getMessages)) {
$messages[] = $message;
}
问题是当我在按钮链接末尾添加变量时#allMessages?id =它不再调用弹出窗口。
Javascript:
$("[data-toggle='popover']").popover();
});
function load_page() {
var selected_page = document.getElementById("selected_page").value;
if (selected_page != "") {
window.location.href = selected_page
//Please note that the value recived,
//in this case selected_page,
//should be a valid url!
//Therefore the value of the
//<option> tag should be itself
//a url !
//ex.: <option value="page.php"> is valid
//<option value="page_1"> is not valid
}
答案 0 :(得分:0)
我无法看到这一点。
模式已经在页面上,只是不可见,所以任何PHP查询都将在呈现页面时完成,而不是在模式被激活时。
我个人在数据属性中发送ID,在AJAX请求中进行处理,然后将结果推送到模态框中。