嗨我有一个模式,我想动态加载从while循环接收的数据,我分配ID,但模式只显示最后一行数据(图像)。从PHP查询加载数据到Modal
这是我的PHP
<script>
var slider_counter2 = 0;
</script>
<?php
$slide_counter1=0;
while($data=$select->fetch()){
$slide_counter1++;
?>
<script>
slider_counter2++;
</script>
<!-- The Modal -->
<div id="myModal_<?php echo $slide_counter1;?>" class="modal">
<!-- Modal content -->
<div class="modal-content">
<span class="close" id="modal_close_btn_<?php echo $slide_counter1;?>">×</span>
<div class="modal-body">
<img class="propertylistboximgfilled" src="../images/user/final_<?php echo $data['property_image1'];?>">
</div>
</div>
</div>
<script type="text/javascript" src="../js/modal.js"></script>
<?php } ?>
这是我的javascript
var modal = document.getElementById('myModal_'+slider_counter2);
// Get the button that opens the modal
var btn = document.getElementById('modalopener_'+slider_counter2);
// Get the <span> element that closes the modal
var span = document.getElementById('modal_close_btn_'+slider_counter2);
// When the user clicks the button, open the modal
btn.onclick = function() {
modal.style.display = "block";
}
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
modal.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
可能是错误在这个....
好的...我已经把我的问题的简化版本放在这里,我需要把一个滑块插入我的模态..滑块将从每个从PHP接收的数据“行”获得6个图像while while循环...你可以指导我,我正在使用jssor循环,请看看这个...这里的代码工作正常,没有模式,http://stackoverflow.com/questions/42157315/loading-images-into-jssor-slider - 从一个while循环 – DragonFire