# images from table into Modal

**URL:** <https://forum.kirupa.com/t/images-from-table-into-modal/644873>\
**Category:** Uncategorized\
**Created:** [November 7, 2020, 3:10pm UTC](https://forum.kirupa.com/t/images-from-table-into-modal/644873 "2020-11-07T15:10:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![RAF166](https://avatars.discourse-cdn.com/v4/letter/r/ba9def/32.png) [@RAF166](https://forum.kirupa.com/u/RAF166)\
**Post date:** [November 7, 2020, 3:10pm UTC](https://forum.kirupa.com/t/images-from-table-into-modal/644873/1 "2020-11-07T15:10:51Z")

</div>

I have a large table of RAF losses in WW2. My plan is to have small size images inside the table beside names. I want to click on the small images and have them open in modal. I have tried so many ways with no success. querySelectorAll doesn’t seem to find images in table nor does any other method I have tried. I do not know much about java or jquery, I make these pages to honour men lost. I can send the whole HTML page if that might help. I am really at a loss… this is about 3 weeks of trying things… with no joy. Any help most appreciated. contact directly if need… dswallow4 ‘at’ cogeco.ca… Thanks Dave

var tbl = document.getElementById(‘dataTable’);  
var modal = document.getElementById(‘myModal’);  
var images = document.querySelectorAll(".myImg");  
var modalImg = document.getElementById(‘modal-image’);  
var captionText = document.getElementById(“alt”);  
for(let i = 0; i \< images.length; i++){  
images[i].onclick = function(){  
modal.style.display = “block”;  
modalImg.src = this.src;  
captionText.innerHTML = this.alt;  
}  
}

---

<div class="post-metadata">

**Author:** ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)\
**Post date:** [November 7, 2020, 9:28pm UTC](https://forum.kirupa.com/t/images-from-table-into-modal/644873/2 "2020-11-07T21:28:38Z")

</div>

Can you post a link to your full HTML page? I wonder if the code is running too early!
