我有一个模式,当前打开一个按钮,似乎无法弄清楚如何将变量传递给它来填充数据库中的动态数据。我在URL中有一些需要发送到模态的变量。
我真正需要做的是用href链接替换打开模态的按钮。
Modal
<!---BUTTON THAT OPENS MODAL--->
<button onclick="document.getElementById('id01').style.display='block'" style="width:auto;">Login</button>
<!---END BUTTON--->
<!---MODAL--->
<div id="id01" class="modal">
<form class="modal-content animate" action="action_page.php">
<div class="container">
<div class="container" style="background-color:#f1f1f1">
<button type="button" onclick="document.getElementById('id01')
.style.display='none'" class="cancelbtn">Cancel</button>
<span class="psw">Forgot <a href="#">password?</a></span>
</div>
</form>
</div>
<!---END MODAL--->
This is what I need to open the modal with (or similar) and pass the variables to it.
<a href="#CGI.SCRIPT_NAME#?viewas=#dtDay#&id=#qEventSub.id#" title="#DateFormat( dtDay, "mmmm d, yyyy" )#" style="color: white;"onclick="document.getElementById('id01').style.display='block'" style="width:auto;>#Day( dtDay )#</a>
答案 0 :(得分:0)
我知道这个!我有这个问题:)
<button type="button" class="btn btn-info btn-sm" data-toggle="modal" data-target="#Comments-<?php echo $job_numb;?>">Comments</button>
<!-- Modal -->
<div id="Comments-<?php echo $job_numb;?>" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Comments for <?php echo html_entity_decode($job_name) . " | " . $job_numb;?></h4>
</div>
<div class="modal-body">
<p><?php echo html_entity_decode(nl2br($comments));?></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
看,我所做的是调用$ job_numb,它是由SQL为每条记录生成的,并将其传递给模态。因此,循环为每个模态创建一个唯一的ID。